I need your help again.
So basically I have a div, id = "parent", which I want to hide along with its contents, I also nested the div in this div with the identifier "nested". The “parent” is wider than the “nested” one, so I want to press the “parent” button to want the hide function to be activated, but if you click the “nested” ones, this hide function will not be activated.
However, what happens is that the function is activated when you press "parent" and when you press "nested". Here is the code:
HTML:
<div id="parent"> <div id="nested"> <p>Contents</p> </div> </div>
JQUERY: (put console.log to represent the hide function)
var parent = $('#parent'); var nested = $('#nested'); parent.not(nested).click(function(){ console.log('Click'); });
It seems like it should be simple, but I can't figure it out! Are my selectors wrong? Is this something jQuery just can't do? Any help is much appreciated!
Thanks!
source share