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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:11:11+00:00 2026-05-13T08:11:11+00:00

I have 16 <li> items. Upon clicking a button, I run the following code

  • 0

I have 16 <li> items.
Upon clicking a button, I run the following code which removes a <li> item.

jQuery('.btnRemoveItem').live("click",function(){
    var obj = this;
    jQuery.post("wp-content/themes/storelocator/include/adm_gallery.php", { deleteImage: 'single', name: jQuery(this).attr('id') },
    function(data){
        if(data.status == 'deleted');
        {
            jQuery(obj).closest('li').fadeOut(400, function() { $(this).remove(); });
            var count = jQuery('#adminGallery ul li').length;
            jQuery('#imageCount').html(count);
        }
    }, "json");

});

This code works and removes the list item. However, doing a item count, still returns 16 items.
I therefore need to bind the event somehow. I thought maybe that $.live would help, but it has no effect.

How should I go around to “bind” the <li> removal?

  • 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-13T08:11:11+00:00Added an answer on May 13, 2026 at 8:11 am

    It is not working because you are not removing the element until it finishes fading out which takes 400ms, meanwhile the rest of the code moves on and the count still sees the soon-to-be-deleted <li>.

    Simply move the two lines below the fadeout to be inside the callback function and it will work as you intend.

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

Sidebar

Related Questions

please consider the following scenario for .net 2.0: I have an event that is
I have a php page which allows a user to sort pieces of information
I have two HTML lists, and am using JQuery sortable to drag between them.
I have a set of data created by another app and stored in XML
I have gotten a program Im working on to load some pictures and display
I have recently figured out that I haven't been using regex properly in my
I was thinking about extending all my controllers from the indexController. I have in
I am using Spring+Hibernate for an operation which requires creating and updating literally hundreds
I have put together a small ASP.NET MVC 2 site that does some very
I am wondering how to ensure that an employee cannot access information from another

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.