Which is better practice on "simple" websites. (very few javascript actions)
a:To attach event/action/function onto an element (div/span/...)
like how this button and click event added to some div:
$( "#create-user" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
b:or in line have element action call a function.
<div id=calc onclick="doCalcFunc(this)">calc something</div>
This is questioned from someone that comes from more of a OO background, java/c#, so have found that prefer B, simple from easily finding what is happening. Maybe it might simply be learning more on web debug tools, but being able to click go to source on an element, and seeing, oh, when you click this element, it will run function X. As to method "A", which I would have to do a search on the source for some function which might be attached to the element ID, or type, or class, or some other indicator for the element.