Element By Path
For a project I’m working on for my employer, I need to be able to back-track my way up the DOM and store a path to a particular element. Because the resulting path will be used in either JavaScript or VBScript (a really terrible language), I can’t really rely on just building a sequence of DOM method calls.
What I’d like to be able to use is something like:
var e= elementByPath( "div#foo.a[4]" );
Given that browsers have to implement this sort of thing for CSS (well, maybe not the indexing), I’m surprised it isn’t in the DOM.
It isn’t too hard to build some JavaScript which will parse this. Read Element By Path »