Based on some very unscientific and very fast tests using .bind vs .click, it represents 15% (approximately) acceleration, as more than 50,000 iterations of each were tested.
This is not enormous, unless you are connecting a huge number of events, but I always think that doing it faster when he is not making any effort is something worthwhile.
My quick and dirty test: http://jsbin.com/ixegu/edit
Other Benefits - Link Multiple Events
, , . .bind, :
$('#link').bind('mouseover focus', function() { ... });
bind(). docs:
$("div.test").bind({
click: function(){
$(this).addClass("active");
},
mouseenter: function(){
$(this).addClass("inside");
},
mouseleave: function(){
$(this).removeClass("inside");
}
});
()
( )
<div id="link">Happy</div>
<div id="otherlink">Sad</div>
function myHandlerFunc(e) {
alert('This is a ' + e.data.myVal + ' function.');
}
$('#link').bind('click', { myVal : 'Happy' } , myHandlerFunc);
$('#otherlink').bind('click', { myVal: 'Sad' }, myHandlerFunc);
" ", "", " ", . . http://jsbin.com/idare/edit .
.