Solved: Prevent jQuery function if elementbyid clicked?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Solved: Prevent jQuery function if elementbyid clicked?

Post 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} 
Last edited by JAB Creations on Sat Feb 23, 2008 9:45 pm, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Prevent jQuery function if elementbyid clicked?

Post by Christopher »

I think:

Code: Select all

$("h2:not(#searchh2)").click(function(){$(this).next('div').BlindToggleVertically(1000,null, 'bounceout');return true;})
(#10850)
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Prevent jQuery function if elementbyid clicked?

Post by JAB Creations »

Thanks Christopher, that worked perfectly! :mrgreen:
Post Reply