JavaScript can get complicated
var tables = document.getElementsByTagName('table'); for (var t = 0; t < tables.length; t++) { var rows = tables[t].getElementsByTagName('tr'); for (var i = 1; i < rows.length; i += 2) { if (!/(^|s)odd(s|$)/.test(rows[i].className)) { rows[i].className += ' odd'; } } }
jQuery can make it easy
jQuery('table tr:nth-child(odd)').addClass('odd');
Separation of concerns
<a href="#" onclick="alert('hello');"><font color="#ff0000"><strong>Click Me</strong></font></a>
Separation of concerns is a web dev principal. We have been using it for years with seperating the concern of content (i.e. HTML) and display (i.e. CSS). It's logical that we do the same with JavaScript, we seperate it from the html. What does that mean? Seperate JavaScript files? Not at all - think the onclick event handler on almost anything in HTML, that is tightly linking the javascript to the element - even if it calls a javascript method in a seperatye file. Separation means that something externally attaches the javascript to the element at runtime, like CSS does for design.
.clicker { color: #FF0000; font-weight: bold; }
.clicker { color: #FF0000; font-weight: bold; }
$(document).ready(function(){ $(".clicker").click(function(){ alert('hello'); }); });
.clicker { color: #FF0000; font-weight: bold; }
$(document).ready(function(){ $(".clicker").click(function(){ alert('hello'); }); });
<span class=”clicker”>Click Me</span>
Wow Factor
Wow Factor
Use VS2010 + jQuery to show off my
Points
Remember it's not the size of the points that matter, it's how you use them.