javascript - jQuery: How to make keyboard Event do the same on click event together -
i need make click event , arrow right make same event
so instead of repeated code
$('#foo').on('click',function() { //do }); $(document).keydown(function(e){ if (e.keycode == 39) { //do same thing above } });
how should it?
thank :)
make them both trigger same function.
$('#foo').on('click', coolfunction); $(document).keydown(function(e){ if (e.keycode == 39) { coolfunction(); } }); function coolfunction() { //same thing }
Comments
Post a Comment