Jquery .click overriding anchor href when I don't want it to?

A few changes here, there's no need to repeat the same selector, and check that the event didn't come from an a tag, like this: $("div. SubSystemHeader"). Click(function(e) { if(e.target.

NodeName == 'A') return; //skip this handler, don't return false $("> div", this). SlideToggle(...); return false; }) You can test it here If the event target was from the a (there are no children of it) then we just exit the handler, returning undefined since we're not explicitly returning false the click event will do it's normal thing...going to the href.

A few changes here, there's no need to repeat the same selector, and check that the event didn't come from an tag, like this: $("div. SubSystemHeader"). Click(function(e) { if(e.target.

NodeName == 'A') return; //skip this handler, don't return false $("> div", this). SlideToggle(...); return false; }); You can test it here. If the event target was from the (there are no children of it) then we just exit the handler, returning undefined, since we're not explicitly returning false the click event will do it's normal thing...going to the href.

You can check the event object of the click and then check the event target - see also api.jquery.com/event.target/ $("div. SubSystemHeader, div. SubSystemHeader").

Click(function(event) { if(event.target.nodeName.toLowerCase() == 'a') return; ... } (didnt test it, but it should work).

This won't work, strings are case sensitive and nodeName is upper-cased. – Nick Craver? Oct 15 '10 at 10:28.

Your problem is return false; which is blocking the default behavior. $("a:eq(0)"). Click(function() { return false; /* does nothing */ }); $("a:eq(1)").

Click(function() { /* go to href */ }); Example on jsFiddle.

I just came across this issue today. I found a very interesting article that might help. It describes the mis(use) of 'return false' and Jquery events (fuelyourcoding.com/jquery-events-stop-mi...).

I haven't tested the following code on your example, but I think this should work. $('. SubSystemHeader a').

Click(function(e){ e.stopPropagation(); }).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions