Another function you'll use quite often for DOM manipulation is dojo.style, which acts as a setter when you pass it a node and a map of style properties as parameters; and as a getter when you pass it a node and a particular style property. In addition to providing an intuitive one-stop shop for style, it protects you from a number of DOM-based browser-specific quirks that otherwise would creep up on you. Here's how it works:

Name:  Styling nodes.jpg
Views: 39
Size:  21.1 KB

I I Set some style properties .. var fooNode = dojo.byld("foo"); dojo.style(fooNode, I
color : "red", background: "white" I border : "blue"
1* ... LOts of interesting things happen in the meanwhi le .. * I
I I Get a style property such as Width ... var props = dojo.style(fooNode, ",.idth");
On a related tangent, you can use any combination of the dojo. hasClass, dojo. add Class and dojo. remove Class functions to inspect and manipulate classes in the same intuitive manner:
var fooNode = dojo.byldl"foo"); if dojo.hasClass (fooNode) {
II do something ...
dojo. addClass (fooNode, "bar"); else {
I Ido something else ...
dojo. removeClass (fooNode, "baz");