I have some javascript code that looks like this:
dojo.query("#maintenanceOpData tr").forEach(function(node, index, nodelist){
if (index % 2 == 0) {
dojo.style(node, {
"backgroundColor": "#FFFFCC"
});
};
});
Everything I find in online documentation shows that dojo.style expects the ID of the DOM element, not the DOM node itself. What can I do? The only other examples show using dojo.query(…).style(…), which applies the style to all nodes. I only want to apply it to every other node, which is why I use the for-each call.
Which version of Dojo are you using? Like JIP says, the code you’ve pasted should work fine ( http://jsfiddle.net/4HXMF/ ), given that you’re using a recent version of Dojo.
Dojo query actually supports many of the new selectors, so you can in fact do: