tags:

views:

36

answers:

2

I'm interested in having my LIs toggle when a user clicks in the blank area of the LI. The LI does contain links that redirect, but in the case when the user clicks on a blank area of the LI I would like the LI to toggle

<li id="58" class="records">
<a href="adadad">Title</a>
<div class="expanded" style="display:none;" id="expanded_58"> STUFF </DIV>
</li>

Example, with the code above, if the user clicks on the LI, and that click isn't on the HREF, I would like the expanded_58 to Toggle.

Thanks!

+2  A: 
$("li.records").click(function(e){
  if (e.target.nodeName == "LI")
    $(".expanded", this).toggle();
});
Jonathan Sampson
+3  A: 

Use this:

$(function(){
    $('li.records').click(function(e){
       if(e.target == this) $('div.expanded', this).toggle();
    });
});
Doug Neiner