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

  • Home
  • SEARCH
  • 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 8508997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:18:49+00:00 2026-06-11T03:18:49+00:00

I have a function that allows me to expand and collapse an unordered list

  • 0

I have a function that allows me to expand and collapse an unordered list by clicking on the list item, but the problem is in the lowest level LI I have a table with a checkbox embedded, and when the user clicks on the table [edit] the background image of the parent li is shown.

The way I see it there are two main routes to solve this, somehow just remove the background image for just the child li or to unbind the click event for the child li. I am trying to unbind the click handler on the lowest level LI, but it just won’t work. Below is a simplified version. A user shouldn’t be able to click on the td cells.

If you view the jsfiddle I can’t add the png files that will completely replicate the problem to where you can see the issue, but as long as the ‘alert’ triggers on the child li you can tell the child li is still clickable.

http://jsfiddle.net/3CgQ6/9/

HTML

<ul id="expList">
  <li>Category 1
     <ul>
        <li class="detailLI"> Category 1.1
           <table>
             <tr><td><input type="checkbox"></td><td>Part A</td></tr>
             <tr><td><input type="checkbox"></td><td>Part B</td></tr>
             <tr><td><input type="checkbox"></td><td>Part C</td></tr>
           </table>
        </li>
        <li class="detailLI"> Category 1.2
           <table>
             <tr><td><input type="checkbox"></td><td>Part D</td></tr>
             <tr><td><input type="checkbox"></td><td>Part E</td></tr>
           </table>
        </li>
     </ul>
  </li>
</ul>

JavaScript

    $('#expList').find('li:has(ul)')    
        .click( function(event) {
            //If line item is expandable but has no line items then call the service to retrieve data
            if($(event.target).hasClass('collapsed') && $(event.target).find('li').length==0){                  
                retrieveResults($(event.target));
            }
            //Toggle the lists if they show or not
            $(event.target).toggleClass('expanded');
            $(event.target).children('ul').slideToggle('medium');
            event.stopPropagation();
            $('.detailLI').unbind("click");
        })
        .addClass('collapsed')
            .removeClass('expanded')
            .children('ul').hide();
  • 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-06-11T03:18:50+00:00Added an answer on June 11, 2026 at 3:18 am

    Use on() and off() to bind/unbind events. All other methods of binding/unbinding have been deprecated as of jQuery 1.7.

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

Sidebar

Related Questions

I have a function that allows users to edit a row in a table
I have a jQuery function that allows a user to create a list of
I have a simple javascript function that allows me to add an item to
Does .NET have some type of built in function that allows filtering on Gridviews?
I'm trying to build a PHP function that allows me to have an array
I have a function that I use quite frequently, which allows me to write
I have the middleware that allows me to check user auth, here is: function
Inside my Controller i have function that runs after user clicks on item, which
I have this upsert function that allows me to modify the fill_rate column of
I currently have a JS function that allows me to load partial content from

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.