Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:44:41+00:00 2026-05-23T16:44:41+00:00

I am creating a web app where I allow the user to manipulate some

  • 0

I am creating a web app where I allow the user to manipulate some data held in Javascript array. Its easy enough to generate a series of divs or an HTML list to represent the array (simply iterating through and adding the HTML) but I also want each array element to have a ‘delete’ button in the HTML that removes the corresponding Javascript array element and then update the HTML list.

To clarify the list would look something like this to the user:

Item 1 (Delete)
Item 2 (Delete)

Ideally I would like the ‘Delete’ link to, when clicked, call a Javascript method with the item index (‘remove_item(index)’ for example).

I have thought of a couple of awkward ways of doing this but I feel this is something that must have been done before and wondered if anyone had a sturdy, fast solution to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:44:41+00:00Added an answer on May 23, 2026 at 4:44 pm

    Grab the inner HTML of the sibling of the delete button, then look for that value in the array. Then remove it, and remove the parent of the delete button from the DOM.

    http://api.jquery.com/siblings/

    http://api.jquery.com/parent/

    <html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                for (var i=0; i<10; i++){
                    var $div = $('<div id="myDiv' + i + '"></div>');
                    $span=$("<span>" + i + "</span>");
                    $button=$('<button type="button" id="button-' + i + '">Delete Me!</button>');
                    $button.click(function(){
                        var id = this.id.split("-")[1];
                        $("#myDiv" + id).remove();
                    });
                    $div.append($span);
                    $div.append($button);
                    $("#wrapper").append($div)
                }
            });
        </script>
    </head>
    <body>
        <div id="wrapper"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to allow a user of my web-app to be able to post
So I am creating a web app, that will give each registered user a
I'm creating a web application installer using WiX. I want to allow the user
i'm creating a web app that's running on an Advantage Database server, not my
I'm creating a web app with Django. Since I'm very familiar with Apache I
I'm creating a web app (locally, so security doesn't matter) in PHP where the
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I am working on creating a web app that will query event logs on
I am interested in creating a web app that uses JSP , Servlets and
I am creating the UI of a web app, and haven't done any back-end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.