Chapter 3. Bringing pages to life with jQuery
This chapter covers
- Getting and setting element attributes
- Storing custom data on elements
- Manipulating element class names
- Setting the contents of DOM elements
- Storing and retrieving custom data on elements
- Getting and setting form element values
- Modifying the DOM tree by adding, moving, or replacing elements
Remember those days (luckily, now fading into memory) when fledgling page authors would try to add pizzazz to their pages with counterproductive abominations such as marquees, blinking text, loud background patterns (that inevitably interfered with the readability of the page text), annoying animated GIFs, and, perhaps worst of all, unsolicited background sounds that would play upon page load (and only served to test how fast a user could close down the browser)?
We’ve come a long way since then. Today’s savvy web developers and designers know better, and use the power given to them by DOM scripting (what us old-timers might once have called Dynamic HTML, or DHTML) to enhance a user’s web experience, rather than showcase annoying tricks.
Whether it’s to incrementally reveal content, create input controls beyond the basic set provided by HTML, or give users the ability to tune pages to their own liking, DOM manipulation has allowed many a web developer to amaze (not annoy) their users.