I am working on a page with a small bit of JavaScript written by someone else. They are in the Pre-jQUery era. It’s all old and crusty code that is hard to read. I think I could have made the same stuff in jQuery using about 5 lines. jQuery just makes web page development so easy. It makes me annoyed just looking at this old stuff.
Example:
var element = document.getElementById("foo");
var visible = element.style;
if (visible.display=='' && element.offsetWidth != undefined && element.offsetHeight != undefined)
{
visible.display = (element.offsetWidth!=0 && element.offsetHeight != 0) ? 'block' : 'none';
}
visible.display = (visible.display=='' || visible.display=='block') ? 'none' : 'block';
in jQuery:
$("#foo").toggle()
Which do you think looks easier?
by the way, at the conference I was at last week, one of the developers did a presentation on using jQuery alongside my employer’s Ajax framework. It was well-received.