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 7664719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:22:33+00:00 2026-05-31T14:22:33+00:00

I have a jQuery triggering a div with live updates every 5 seconds. That

  • 0

I have a jQuery triggering a div with live updates every 5 seconds. That works fine. Sometimes those updates should be deleted immediately.

jQuery generates html like this:

<form>

<div id="live1">Aha I love you too
<input id="live1" type="hidden" value="1"><label id="livedel1">Delete 1</label>
</div>

<div id="live2">Thx man
<input id="live2" type="hidden" value="2"><label id="livedel2">Delete 2</label>
</div>

</form>

… and so on.

I need some help with HTML and jQuery how to send/separate specific id to jQuery so it can be deleted, since I’m kinda not into jQuery vals. Deletion is not a problem, just for jQuery to grab specific id.

Recommendations in HTML and jQuery are welcome and upper HTML can be changed to xy code no problem.

  • 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-31T14:22:34+00:00Added an answer on May 31, 2026 at 2:22 pm

    First, you have multiple elements with the same id. This is not valid HTML and will cause you problems.

    If you want to delete a div when the label is clicked, you could do this:

    <form>
    
    <div id="live1" class="live">Aha I love you too
    <input id="livehidden1" type="hidden" value="1"><label id="livedel1">Delete 1</label>
    </div>
    
    <div id="live2" class="live">Thx man
    <input id="livehidden2" type="hidden" value="2"><label id="livedel2">Delete 2</label>
    </div>
    
    </form>
    

    jQuery:

    $('.live').on('click', 'label', function() {
        $(this).closest('.live').remove();
    });
    

    The key is to fix your IDs to be valid, and add a class live to the parent elements. Then you can use jQuery to search up the DOM and delete the parent live element. But, it is difficult from your question to tell if this is what you really want to do.

    If you don’t want to change your html, aside from the invalid IDs, you would need to do something like this:

    $('form').on('click', 'label', function() {
        var num = $(this).attr('id').replace(/livedel/, '');
        $('#live'+num).remove();
    });
    

    This makes the assumption that your html may vary from item to item. If your structure is always the same, you don’t have to mess with IDs and can just use .parent(), although as I am suggesting, it is not very robust:

    $('form').on('click', 'label', function() {
        $(this).parent().remove();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jquery code that uses the live method of triggering events: $(document).ready(function()
basically I have a function that resizes elements accordingly with jquery triggering the function
The jquery datepicker plugin works, but I'd like to have onSelect triggering a function
I have jQuery to select all font elements that are children of the element
I have jquery validation code which is working fine in ff but the same
Say I have jquery code like this: html += '<div class=index>' + item.index +
does jquery have any plugin that prevents entering any input to a textbox that
I have a question regarding jQuery. I have multiple images that are, in essence,
I would like to have a form triggering submit after a few seconds of
I have a jQuery UI Autocomplete control that fires an Ajax request when minLength

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.