One link, two different click effects?
Hello Jquery Experts!
I have a list of faculty which allows a user to click on any name and go to that person's website. However! I would like to override this behavior if a person CTRL+CLICKS on the name, instead invoking a toggleClass('selected') function which can then be used for filtering.
The code for invoking the CTRL+CLICK functionality looks like so...
-
$(function() {
$('#myButton').bind('ctrlclick',function() {
$(this).toggleClass('hoover');
return false;
});
});
And the corresponding HTML is this:
-
<p><a id="myButton" href="http://www.google.com">MY BUTTON but here</a></p>
When I CTRL+CLICK, it seems to ignore the class switching and opens Google in another window/tab. When I click without CTRL, I get a Stack Overflow error alert before it opens Google in the same window.
If I replace the url with "javascript:;" or "" the CTRL+CLICK does work, but just clicking it still produces the stack overflow error.
Anybody have any ideas?
I sure do appreciate ya.
Arlen