I've read the posts of live()
versus delegate()
versus on()
, and understand the position.
I also understand how click()
is just a shortcut for on()
, and how the two statements are identical.
$( "#clickTarget" ).click(function() {alert( "Handler for .click() called." );});
$( "#onTarget" ).on('click',function() {alert( "Handler for .on() called." );});
My question is whether there is any advantage of using bind()
over on()
? Note that the documentation states "As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document." For instance, if my element exists upon writing of the DOM, it seems to make sense. If so, is there a shortcut version of bind()
which binds on click?
$( "#bindTarget" ).bind( "click", function() {alert( "Handler for .bind() called" );});