Use this:

<ul>
    <li><input type="radio" name="list" value="volvo">Volvo <button>delete</button></li>
    <li><input type="radio" name="list" value="saab">Saab <button>delete</button></li>
    <li><input type="radio" name="list" value="mercedes">Mercedes <button>delete</button></li>
    <li><input type="radio" name="list" value="mercedes">Mercedes <button>delete</button></li>
</ul>

Then add event listeners to each button that removes the parent <li> from the list (Demo at jsfiddle.net).

Answer from Bergi on Stack Overflow
🌐
W3Schools
w3schools.com › howto › howto_css_delete_modal.asp
How To Create a Delete Confirmation Modal
Login Form Signup Form Checkout ... Upload Button Empty Input Validation · Filter List Filter Table Filter Elements Filter Dropdown Sort List Sort Table · Zebra Striped Table Center Tables Full-width Table Nested Table Side-by-side Tables Responsive Tables Comparison Table · Fullscreen Video Modal Boxes Delete Modal Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Color Picker Email Field Tooltips Display Element Hover Popups Collapsible Calendar HTML Includes To ...
Discussions

Custom Delete button in html block
Does anyone know how to create a custom 'Delete' button that could be put in an html block in the Details view of a datapage. I need to use Rules to allow/disallow the deleting of a record. The standard 'Delete' button allows deletion of all records. So a custom button in an html block in a Secti... More on forums.caspio.com
🌐 forums.caspio.com
December 13, 2021
Make Delete and Edit Buttons Work
Please help me to finish my To Do App: Add click event on button “Remove” - So that by click on button “REMOVE” created item would be removed from localstorage as well. Add click event on button “Edit” - So that created item could be edited in localstorage as well. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
September 19, 2022
html - How can i make a delete Button? - Stack Overflow
So i have made a button that generates random cards when i click on it. when i click on the card it will show two text fields and two buttons. Now i wanna make a button (in my code the button sho... More on stackoverflow.com
🌐 stackoverflow.com
Delete button is deleting everything - html and javascript
when I dynamically create a li and add a delete button to it the delete button deletes all elments in the ul. Also, I am unable to create another element in the ul after the delete button is clicked. I am unsure how to fix this. Any help is appreciated! Todo List Todo List Add Task ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
March 30, 2020
🌐
Medium
medium.com › @emclawson1 › adding-a-delete-button-in-4-easy-steps-85b06f53da6b
Adding a Delete Button in 4 Easy Steps | by E Clawson | Medium
August 29, 2021 - Step 2 — Get this button to display on the page. Since the cat emoji is a child element of the larger parent element ul(unordered list), and I want the delete button to display next to this cat, then I also want the delete button to be a child of the ul from the HTML file.
🌐
CodePen
codepen.io › jcsb › pen › qzPyRV
Delete Button / Trash Can
Minimize HTML Editor · Fold All · Unfold All · <button class="btn btn-delete"> <span class="mdi mdi-delete mdi-24px"></span> <span class="mdi mdi-delete-empty mdi-24px"></span> <span>Delete</span> </button> ! CSS Options · Format CSS · ...
🌐
Caspio
forums.caspio.com › bridge framework › user javascript and css discussions
Custom Delete button in html block
December 13, 2021 - Does anyone know how to create a custom 'Delete' button that could be put in an html block in the Details view of a datapage. I need to use Rules to allow/disallow the deleting of a record. The standard 'Delete' button allows deletion of all records...
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Make Delete and Edit Buttons Work - JavaScript
September 19, 2022 - Please help me to finish my To Do App: Add click event on button “Remove” - So that by click on button “REMOVE” created item would be removed from localstorage as well. Add click event on button “Edit” - So that create…
🌐
Sololearn
sololearn.com › en › Discuss › 254004 › how-to-put-a-working-delete-button-on-my-html-page
How to put a working "delete" button on my html page
Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
Find elsewhere
🌐
WordPress
developer.wordpress.org › block-editor › how-to-guides › data-basics › 5-adding-a-delete-button
Adding a delete button – Block Editor Handbook | Developer.WordPress.org
Let’s start by creating the DeletePageButton component and updating the user interface of our PagesList component: import { Button } from '@wordpress/components'; import { decodeEntities } from '@wordpress/html-entities'; const DeletePageButton = () => ( <Button variant="primary"> Delete </Button> ) function PagesList( { hasResolved, pages } ) { if ( !
🌐
CodePen
codepen.io › sumandevs › pen › xebEEX
Stylish delete button
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Stylish Delete Button</title> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"> </head> <body> <div class="main-box"> <div class="icon-box"> <i class="fas fa-trash-alt icon trash-icon"></i> <i class="fas fa-question icon question-icon"></i> <i class="fas fa-check icon check-icon"></i> </div> <div class="text-box"> <span class="delete-text">Delete</span> <span class="sure-text">Are you sure?</span> <span class="confirm-text">Done!</span> </div> </div> <!-- End main-box --> </body> </html> !
🌐
Medium
medium.com › @brindaxo5 › creating-a-delete-button-for-your-javascript-application-b242deab0d36
Creating a delete button for your javascript application | by Brinda Behal 💋 | Medium
June 4, 2022 - function renderHomes(home){let deleteHome = document.createElement("button") deleteHome.setAttribute('id', 'delete-btn') deleteHome.innerText = "delete listing" deleteHome.addEventListener("click", function(event) { console.log("test222 home id ", homeDiv.id) if (event.target.id === 'delete-btn') { fetch(`http://localhost:3000/homes/${home.id}`, { method: "DELETE", headers: { "content-type": "application/json", accept: "application/json" } }).then(resp => resp.json()) .then(() => { homeDiv.innerHTML = ""; const home = homeDiv.querySelector(`[data-id='${homeDiv.id}']`); home.remove(); }) } })})
🌐
W3Schools
w3schools.com › icons › tryit.asp
W3Schools Tryit Editor - delete
The W3Schools online code editor allows you to edit code and view the result in your browser
Top answer
1 of 1
2

Your delete selector is wrong, try .card .delete:

$(document).ready(function() {
  $("button.plus").on("click", function() {
    var newCard = $('#cardPrototype').clone(true);
    $(newCard).css('display', 'block').removeAttr('id');
    $('#newCardHolder').append(newCard);
  });

  $('body').on('click', '.card', function() {
    $(this).find('form').show();
    $(this).find('span').remove();

  });

  /*delete button*/
  $('body').on('click', '.card .delete', function() {
    $(this).closest('.card').remove();
  });
});
.input-feld {
  font-family: TheSans Swisscom;
  margin: 3px;
  width: 260px;
}
.card {
  width: 300px;
  margin-right: 5px;
  margin-left: 5px;
  margin-bottom: 10px;
  float: left;
  padding: 10px;
  background-color: #BBBBBB;
  border: 1px solid #ccc;
  border-radius: 10px;
  position: relative;
}
.delete {
  font-family: 'TheSans Swisscom';
  right: 12px;
  top: 0;
  position: absolute;
}
.speichern {
  font-family: 'TheSans Swisscom';
  background-color: greenyellow;
}
.abbrechen {
  font-family: "TheSans Swisscom";
  background-color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="plus">
  <div class="item">
    <p>+</p>

  </div>
</button>

<div id="newCardHolder">

</div>

<div id="cardPrototype" class="card" style="display:none;">
  <p class="delete">x</p>
  <span>Title</span>
  <form name="theform" style="display:none;">
    <input class="input-feld" type="text">
    <br>
    <input class="input-feld " type="text">
    <br>
    <input class="speichern" type="button" onClick="new Person()" value="Speichern">
    <input class="abbrechen" type="button" onClick="new Person()" value="Abbrechen">
  </form>
</div>

Top answer
1 of 5
2

Why not isolate the forms and pass the ID to the action page?

<table>
    <tr>
        <td>Item 1</td>
        <td><form action='action.php?id=1' method='post'><input type='submit' value='X'></form></td>
    </tr>
    <tr>
        <td>Item 2</td>
        <td><form action='action.php?id=2' method='post'><input type='submit' value='X'></form></td>
    </tr>
</table>
2 of 5
1

You can write names of submit buttons as set of facts and their values, for example name='set1(fact1:value2,fact2:value2,...)'. Then search for submitted set and get fact value. A PHP class PageFacts below can do this. You can check if set is posted using condition if (PageFacts::is('del')) and get value of fact with statement $itemID = PageFacts::get('del', 'id'). Form with submit buttons can look like:

<form method="post">
    ... item [0] text/input
    <input type="submit" name="del(id:0)" value="Del">
    ... item [1] text/input
    <input type="submit" name="del(id:1)" value="Del">
    ... item [2] text/input
    <input type="submit" name="del(id:2)" value="Del">
    ...
    ...
    <input type="submit" name="chng" value="Chng">
</form>

An example of PHP code that deletes table item with itemID can be:

if (PageFacts::is('del')) {
    $itemID = PageFacts::get('del', 'id');
    // Delete $itemID
    deleteTableItem($itemID);
}

// or for multiple facts like del(cid:2,id:0)
if (PageFacts::is('del')) {
    $cartID = PageFacts::get('del', 'cid');
    $itemID = PageFacts::get('del', 'id');

    // Delete $itemID from $cartID
    deleteCartItem($cartID, $itemID);
}

PageFacts PHP code:

class PageFacts {

    // Gets fact value from posted set
    // $s ... name of a set
    // $f ... name of a fact
    // returns - value of fact $f in set $s
    //         - TRUE  if set $s exists but fact $f doesn't exist
    //         - FALSE if set $s doesn't exist
    public static function get($s, $f = NULL) {
        // Regex pattern to search for set $s
        $ps = "/^\s*$s\s*\((.*)\)\s*$/";
        // Search POSTed names (variable $v is not used)
        foreach ($_POST as $key => $v) {
            $ok = preg_match($ps, $key, $matches);
            if ($ok && isset($matches[1])) {
                // If $f is not passed return TRUE, means set $s exists regardless of fact $f
                if (!isset($f)) {
                    return TRUE;
                }
                // Otherwise return value of fact $f
                // use regex pattern to search in list of fact:value items separated by a comma
                $pf = "/^\s*$f\s*\:\s*(.+)\s*$/";
                foreach (explode(',', $matches[1]) as $fv) {
                    $ok = preg_match($pf, $fv, $matches);
                    if ($ok && isset($matches[1])) {
                        return $matches[1];
                    }
                }
            }
        }
        return FALSE;
    }
    // Checks if set $s is posted
    public static function is($s) {
        return self::get($s);
    }
}
🌐
DEV Community
dev.to › designyff › delete-button-with-confirmation-a-step-by-step-guide-4ph8
Delete button with confirmation - A step-by-step guide - DEV Community
October 4, 2022 - Tutorial on how to create a delete button that transforms to "Confirm delete", on click - CSS... Tagged with css, webdev, tutorial, html.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Working with delete button in javascript - JavaScript - The freeCodeCamp Forum
August 28, 2018 - Just trying out these using a video tutorial but the delete function isn’t working.I’v checked this more than 10 times and still can’t find the error,please I need your help HTML FILE <!DOCTYPE html> <html lang="en"> …
Top answer
1 of 1
1

First of all u can't repeat names so u should change delt function's name

As a recomendation try to name functions according it's functionality

function deleteItem(e){
  console.log("Button element", e)
  e.parentElement.remove()
}
<ul>
  <li>Item 1 <button onclick="deleteItem(this)">Delete</button></li>
  <li>Item 2 <button onclick="deleteItem(this)">Delete</button></li>
  <li>Item 3 <button onclick="deleteItem(this)">Delete</button></li>
  <li>Item 4 <button onclick="deleteItem(this)">Delete</button></li>
  <li>Item 5 <button onclick="deleteItem(this)">Delete</button></li>
</ul>

By writing deleteItem(this) you pass element object to function

If you want your button to pass event to function then just change this for event

Btw, it's not a good practice to have your HTML && JS code in the same place, so you should do it this way

window.addEventListener("DOMContentLoaded", function(event){
  // Once DOM is loaded add onclick function
  // Select all buttons with class "btn-delete"
  document.querySelectorAll('button.btn-delete').forEach(el => {
    // Walk each selected button and set onclick function
    // remember to declare event function within a wrapper if you're gonna pass a var
    el.onclick = () => deleteItem(el)
    /* "() => Code" is called arrow function
    * it's the same as a regular anonymous function
      function(){Code}
    */
    // if you want to just execute the function
    // el.onclick = deleteItem
  })
});
// Declare your function outer the DOMContentLoaded event listener
function deleteItem(e){
  // e is the element object, so you do not need to get .target
  e.parentElement.remove()
}
<ul>
  <li>Item 1 <button class="btn-delete">Delete</button></li>
  <li>Item 2 <button class="btn-delete">Delete</button></li>
  <li>Item 3 <button class="btn-delete">Delete</button></li>
  <li>Item 4 <button class="btn-delete">Delete</button></li>
  <li>Item 5 <button class="btn-delete">Delete</button></li>
</ul>

They both works the same, but it'd be better for you to get used to that organization so when your code grows up it would not be spaghetti code

If you want to know more about that check this link

🌐
SitePoint
sitepoint.com › php
Best Practices Question: A delete button - PHP - SitePoint Forums | Web Development & Design Community
July 20, 2010 - In a site I’m working on this is the code for my delete button. <form action="<?= PAMWF_WEBROOT ?>/episodeofcare" method="POST" class="delete"> <span class="confirmMessage">You are about to delete an episode of care. …