Posts Tagged ‘jquery’

Today’s Learning: binding more than one events in jquery

November 21, 2012 Leave a comment

To call a custom event handler when an event fires, we can use “.bind()” jquery method as described below :

$(‘#foo’).bind(‘click’, function(){
//do something on click event fire

To bind more than one events to one element, we can include each event in “.bind()” method separated by space :

$(‘#foo’).bind(‘click mouseover keyup …’, function(){
//do something on event fire

To bind multiple event handlers to one element (As of jQuery 1.4) :

focusout: function() {
// do something on focusout
mouseover: function() {
// do something on mouseover
click: function() {
// do something on click

Categories: Java Script Tags: ,