I have an xpath
//tbody[1]/tr[1]/td[3]/b[1]/a[1]
and would like a Jquery equivalent css expression following this format:
tbody:eq(0)>tr:eq(0)>td:eq(2)>b:eq(0)>a:eq(0)
I expected $("tbody:eq(0)>tr:eq(0)>td:eq(2)>b:eq(0)>a:eq(0)").length to return a match but nothing is found.
neither does $("tr:eq(0)>td:eq(2)>b:eq(0)>a:eq(0)").length or $("td:eq(2)>b:eq(0)>a:eq(0)").length returns any match.
$("b:eq(0)>a:eq(0)").length however is found.
Why does the latter work but the former starting at tr:eq(0), and td:eq(2), doesn’t work ?
That translation of the XPath to a jQuery selector looks fine to me, and it seems to work:
Live example
HTML:
JavaScript using jQuery:
I get the alert that the match length is
1(as expected), and the resulting highlighted link looks like the right one to me.