Reputation: 5
$(this).parent().parent()
.children(this.attr("tagName").toLowerCase())
.css("background-color", "yellow");
xpath:
/html/body/div/table/tr/td/b/a
$(this).tagName
is Anchor <a>
the problem with this is that children() looks at the immediate children of $(this).parent().parent()
. Hence it will highlight <b>
instead of <a>
i need a way to ignore this immediate children restriction, and select <a>
not `
Upvotes: 0
Views: 662
Reputation: 625467
Use find()
to search all descendants:
$(this).parent().parent()
.find(this.attr("tagName").toLowerCase())
.css("background-color", "yellow");
Upvotes: 2
Reputation: 540
Try:
$(this).css("background-color", "yellow");
Unless you are trying to highlight all tags at the same level as "this" in which case try:
$(this).siblings("a").css("background-color", "yellow");
Upvotes: 0