What are the differences between using
$("#element").click(function() { alert("test"); });
and
<div id="element" onclick="alert('test');"></div>
Is there any difference in performance, functionality or anything else? Should I be using the jQuery way, when I can simply use an onclick attribute?
Why Inline JavaScript Code Is Such A Bad Thing
and
Unobtrusive JavaScript
It’s also always better to use a framework for binding javascript events, since there are cross-browser things you need to take care of yourself if you don’t (attachEvent..).