Where do you personally prefer to put html tag handlers with JQuery-powered Html page and why: html tag element or document.ready function?
<a onclick="javascript:foo()" />
...
function foo() {
...
}
or
<a id="mytag" />
...
$(document).ready(function() {
$("#mytag").click(function() { ... });
})
The version with the handler inside of
$(document).readyis better. 1) the code use local and not global functions. It is quickly and you can access to local variables declared inside of$(document).readyfunctions 2) you are sure that the code ofonclickfunction is loaded before the user able to click it. 3) It is better from the design point of view.