3 ms·
I just wrapped up some code I've used in similar situations: https://github.com/rcs/jQuery.relativeSelector https://github.com/rcs/jQuery.relativeSelector Ins
by rcsorensen 14y ago
I just wrapped up some code I've used in similar situations:
https://github.com/rcs/jQuery.relativeSelector https://github.com/rcs/jQuery.relativeSelector
Instead of going all the way to the body, this will find a selector that works given the structure of the page.
For instance, a page like:
<body><div id="firstdiv">Target!</div></body>
you can get "#firstdiv" back.
For something like
<body><div id="#firstClass"><div class="firstClass"><div>Target!</div></div></div></body>
You can get "#firstClass div:eq(0)".