jQuery KeyUp and Click

Tom picture Tom · May 3, 2011 · Viewed 26.5k times · Source

I was wondering how you can do .keyup() and .click() for the same #id?

i.e. essentially I want to validate the #id when both the user attempts to hit enter or hits the #search button.

Thanks alot

Answer

Blender picture Blender · May 3, 2011
$('#foo').bind('click keyup', function(event) {
  ...

You'll have to add some logic, as the event type changes, but it should work with enough if blocks.