Recently I’ve been discovering the joys of DOM scripting. Remember the first time you pulled text from database to a Web page, and that sudden realization that you’d never write a static page again? It was kinda like that.
Many of us have used
getElementById to dip our toes in the murky waters of DOM scripting; easily changing the styles of an
id with something as simple as:
document.getElementById('thing').style.background = 'yellow'
But DOM scripting is much more than
getElementById. Elements can be isolated and manipulated without having an
id at all. To demonstrate this, and to get you thinking, I’ve put together a simple function which redefines the styles of a class. It’s in my shiny new sandbox, an area I created for such experiments.