I\'m writing a GreaseMonkey script where I\'m iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The
In javascript, you could attach a custom ID field to the node
if(node.id) { node.myId = node.id; } else { node.myId = createId(); } // store myId
It's a bit of hack, but it'll give each and every node an id you can use. Of course, document.getElementById() won't pay attention to it.
document.getElementById()