SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's wrong with my jQuery function?

    I'm trying to show all LIs that are hidden inside the parent UL when clicking on a link inside of an LI.

    Structure:

    <ul id="stuff">
    <li>something</li>
    <li>something else</li>
    <li><a href="#" class="link">link</a></li>
    </ul>

    Code:
    $(".link", "#stuff").bind("click", function(e){
    	$(this).parent("ul").children("li").show();
    });

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The way you coded it didn't seem right to be so i tweaked your code a little bit and it works now

    Code JavaScript:
    $(".link").bind("click", function(e){
        $("#stuff").children("li").show();
    });


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •