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

I have a long list of items where clicking on an item may move
I have many items inside a list control. I want each item to have
I have some items in my .emacs that I don't want to run if
I have some items called tickers which can be created and subscribed to. When
I have t he following list item: <li class=item id=44> <div class=name>Bogstadveien</div> <div> <span
I have a QTreeView to which I set a subclassed DomModel:QAbstractItemModel. Each item is
I have an app running which looks at items in a queue, then based
I have an array which contains 2 types of items (lets call them type
rbnResubmission.Items.FindByValue(Yes).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); rbnResubmission.Items.FindByValue(No).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); So I have these click events for showing rows in
I have one command button for task add to cart, it means when items

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.