Running into a spot of trouble and basically trying to create a variable which can be used as a selector. eg
$('a').click(function(){
var selector = $(this).dompath();
});
HTML:
html
body
div
div /div
/div
ul
li
li
/ul
div
ul
li
li
li hello world
/ul
/div
body
html
this would then return something like
path = html body div ul li:contains('hello world')
then i could use this in a selector to select this div so if i did like
$(path).text() would return "hello world"
many thanks!
Perhaps something like this:
This modified a method from another question to go through, and add in the full text contents of the tag via a
:contains()operator only if the tag has no children tags.I had tested with this method:
Against this:
The results of clicking on p then get output as: