Unobtrusive JavaScript Programming

0
126

I’ve been studying/reading up on Unobtrusive JavaScript lately.If you go looking, you’ll find that a lot of sites set up JavaScript event handlers using HTML attributes, like this:

<a href="…" onclick="JavaScript code here">…</a>

This is the JavaScript equivalent of assigning CSS properties to your elements using the HTML style attribute. It’s messy, it violates the principle of keeping code for dynamic behavior separate from your document content, and it’s so 1998.