What is a way to uniquely identify all DOM nodes in an HTML document. To illustrate what I mean, here is a (fictional) example:
- Script X randomly selects a DOM node from document.html.
- Script X needs to tell script Y which DOM node it has chosen.
- How does script X uniquely identify the DOM node it has chosen so that script Y knows exactly which node it is in document.html?
I'm really interested in how to uniquely identify the DOM node so that the script Y can identify it and manipulate it. Preferably, it should work with text nodes as well. I was thinking of XPath maybe, but I'm not sure how to generate a unique XPath to any given node.