I have a huge jQuery application, and I\'m using the below two methods for click events.
First method
Difference in works. If you use click(), you can add several functions, but if you use an attribute, only one function will be executed - the last one.
DEMO
HTML
Click #JQuery
Click #Attr
JavaScript
$('#JQueryClick').click(function(){alert('1')})
$('#JQueryClick').click(function(){alert('2')})
$('#JQueryAttrClick').attr('onClick'," alert('1')" ) //This doesn't work
$('#JQueryAttrClick').attr('onClick'," alert('2')" )
If we are talking about performance, in any case directly using is always faster, but using of an attribute, you will be able to assign only one function.