jQuery - override preventDefault() when click + ctrl pressed -
i using preventdefault()
preventing default behavior of an anchor button, want make button default behavior when clicked keyboard ctrl
button,
js code
$('a').click(function(e){ e.preventdefault(); });
html code
<a href="http://google.com">go best search engine</a>
here playground: http://jsfiddle.net/skdua/
$('a').click(function(e) { if (!e.ctrlkey) { e.preventdefault(); } });
other intertesting options:
e.altkey
- check if alt pressede.shiftkey
- check if shift pressede.button
- distinguish between right, left of middle mouse clickse.which
- same above, works keyboard- full documentation here
one more note, asked documentation seem interested ;)
it's possible debug in jsfiddle - put debugger
in js code , run usual. browser (i use chrome) stop on debugging line, , examine e
object in watches:
Comments
Post a Comment