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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:27:57+00:00 2026-05-28T02:27:57+00:00

I’m having some issues with removing some HTML elements. Just a few words about

  • 0

I’m having some issues with removing some HTML elements.

Just a few words about my code.

I’m cloning <ul> and then showing its content using a popup dialog. Then in 2dim array where I’m saving the <li> corresponding objects between the original and the cloned. So, removing from the cloned one and confirming gives results in the original <ul>.

The problem I am experiencing is when adding jQuery animation and removing in its callback function probably because of the “for” loop. Then, when removing additionally for a second time without closing the dialog window, the bugs come out by removing elements improperly!

If you’re not witnessing it from the first, try playing little bit more, it won’t be long
until you see it!

Here’s the difference
working without .hide animation : http://jsfiddle.net/TTGr7/1/

buggy with animation: http://jsfiddle.net/TTGr7/2/

The key part and the difference is in that section of the code:

 del.click(function() {
        var len = markedForDel.b.length;
        if (len > 0) {
            var confirmation = confirm('Delete marked groups');
            if (confirmation) {
                for (var i = 0; i < len; i++) {
                    markedForDel.a[i].remove();
                    markedForDel.b[i].remove();
                    //markedForDel.a.splice(i,1);
                    //markedForDel.b.splice(i,1);
                }
            }
        }
    });

and

del.click(function() {
    var len = markedForDel.b.length;
    if (len > 0) {
        var confirmation = confirm('Delete marked groups');
        if (confirmation) {
            for (var i = 0; i < len; i++) {
                markedForDel.a[i].hide(function(){
                    markedForDel.a[i].remove();
                });
                markedForDel.b[i].remove();
                //markedForDel.a.splice(i,1);
                //markedForDel.b.splice(i,1);
            }
        }
    }
});

So I really need to keep the .hide animation and still remove groups properly.

So I’m really counting on your kind help,
BR

  • 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-28T02:27:58+00:00Added an answer on May 28, 2026 at 2:27 am

    If the for loop has incremented the value of i by the time the hide callback is invoked, then you will pass the wrong element to remove. Try this, instead:

    markedForDel.a[i].hide(function() {
        $(this).remove();
    });
    

    Within the hide method’s callback, this is set to the element that was just hidden.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.