Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

Call function on mouse click or Enter keypress


Average rating
(3 votes)

Typically useful on anchor elements for which following the link should produce javascript functionality instead of the default action (following the URL).

Function binds mouse click and enter keypress to a specified element, and calls the specified function. The default action (e.g. following the href for an anchor) is prevented.

Release 1.2+ supports binding to more than one element, because the callback function is aware of the target of the click / enter keypress.

Usage:

$.clickOrEnter(yourElement,yourFunction);

e.g.
$.clickOrEnter('a',popup);

This essentially replaces the style of

<a href="javascript:function();">Foo</a>
<a href="foo.html" onclick="function();" onkeypress="function();">Bar</a>

which are inaccessible / obtrusive.

Releases

Official releasesDateSizeLinksStatus
1.22007-Oct-201.03 KBRecommended for 1.0.xThis is currently the recommended release for 1.0.x.
1.0-First release2007-Sep-30909 bytesRecommended for 1.1.xThis is currently the recommended release for 1.1.x.