I recently read a blog post. In it, the author told readers to wire up all their "onclick" events not inline, but when the DOM's ready, like this (jQuery example):
<script type="text/javascript">
$(document).ready(function() {
$("myElement").click(...
});
</script>
This, for all the elements on the page with events attached to them. And that script block, with all its wirings, should go at the end of the page.
He said that setting it in-line was more difficult to maintain:
<span id="myElement" onclick="...">moo</span>
But he didn't say why.
Is this true in others' experiences? Is it a better practice to do this? What are its advantages?
Thanks.