It gave me migraines till I discovered jQuery. Now I can validate a form with some simple CSS and a couple of lines of jQuery code. And today I had a rather odd requirement to toggle the colour of cells in a table when you click on them. In the old days, I wouldn’t even have attempted this. In my new jQuery heaven, I did this:
(document).ready(function() {
$("td.standard").click(
function(){
var currentclass = $(this).attr("class");
if (currentclass.indexOf("highlightcell") == -1) {
$(this).addClass("highlightcell");
} else {
$(this).removeClass("highlightcell");
}
}
);
});
VoilĂ !