jquery .on() method | .on() in jquery

New Event API
The new .on() and .off() APIs bring together all the ways of attaching events to a document in jQuery.  $(el).on ()  gives the developers an unified way of binding events for any event types, direct and delegated events. It also allows you to bind more than one events at the same time by passing an object .
$(elements).on(events [, selector] [, data] , handler);
$(elements).off([ events ] [, selector] [, handler]);
 // An example of binding a click event in before version 1.7 and version 1.7 is illustrated below:
 $(“a#refulz”).click(Handler);  // Click event before jQuery 1.7
  $(“a#refulz”).bind(“click”, Handler); // Binding click event before jQuery 1.7
 $(“a#refulz”).on(“click”, Handler); // Click event in jQuery 1.7 
 // Similar example for .delegate() and .undelegate() methods is shown below:
$(‘.container’).delegate(‘a.refulz, ‘click’, Handler);

$(‘.container’).undelegate(‘a.refulz, ‘click’, Handler); 

 //Above code can be replaced by the following code in the version 1.7 
 $(‘.container’).on(‘click’, ‘a.refulz, Handler);
$(‘.container’).off(‘click’, ‘a.refulz, Handler);



I Am suresh(suresh kumar )a Web developer,Freelancer,webdesigner,UI developer from bangalore. Got 6+ yrs of IT experience . I specialize in standards-based XHTML, CSS and JavaScript web development. Each site I develop is built to be search engine friendly (SEO), using the latest development principles and techniques.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *