jQuery: click function exlude children.

Posted by superUntitled on Stack Overflow See other posts from Stack Overflow or by superUntitled
Published on 2010-03-16T18:58:57Z Indexed on 2010/03/16 19:01 UTC
Read the original article Hit count: 183

Filed under:

Trying to wrap my head around the jQuery ".not()" function, and running into a problem. I would like to have the parent div to be "clickable" but if a user clicks on a child element, the script is not called.

$(this).not(children()).click(function(){
   $(".example").fadeOut("fast");
});

the html:

<div class="example">
   <div>
      <p>This content is not affected by clicks.</p>
   </div>
</div>

© Stack Overflow or respective owner

Related posts about jQuery