jquery not in a child div (can I use find?)

akattelove

New Member
I am trying to select a whole div but not a specific div which is inside the main div. Example is as follows:\[code\]<div id="main_holder"> <div id="secondHolder"> <div id="thirdHolder"> <div id="divIdoNotWantToUse" class="notUsed"></div> </div> </div></div>\[/code\]I am trying a simple click to see that when I click on the div, it shouldn't get the alert.\[code\]$('#main_holder').not('#main_holder.notUsed').click( function(event) { alert( 'pullmenu clicked' );});\[/code\]It's not working, so what is the best approach? Is there a way to use the find in a not selector?example this works: \[code\]$('#main_holder').find('#divIdoNotWantToUse').css({ border: '5px solid red' });\[/code\]Solution by Arun:\[code\]$('#main_holder').click( function(event) { if(!$(event.target).closest('.notUsed').length) { alert( 'pullmenu clicked' ); }});\[/code\]
 
Back
Top