Page 1 of 1

Solved: Prevent jQuery function if elementbyid clicked?

Posted: Sat Feb 23, 2008 9:05 pm
by JAB Creations
I like the following jQuery function...

Code: Select all

$("h2").click(function(){$(this).next('div').BlindToggleVertically(1000,null, 'bounceout');return true;})

However I don't want it to trigger if a visitor clicks on an h2 element with the id of 'searchh2'. I tried the following though it does not work...

Code: Select all

if (!document.getElementById("searchh2")) {//script here} 

Re: Prevent jQuery function if elementbyid clicked?

Posted: Sat Feb 23, 2008 9:39 pm
by Christopher
I think:

Code: Select all

$("h2:not(#searchh2)").click(function(){$(this).next('div').BlindToggleVertically(1000,null, 'bounceout');return true;})

Re: Prevent jQuery function if elementbyid clicked?

Posted: Sat Feb 23, 2008 9:45 pm
by JAB Creations
Thanks Christopher, that worked perfectly! :mrgreen: