Tool to convert XPath to jQuery selector?

Firebug can display xpath for any DOM element in the HTML view. I was wondering if there is a way to convert xpath to a jQuery selector? (I prefer not to do it manually)

This will save me a lot of time in finding the right selector for elements that don't have an identifier and are deep in the DOM hierarchy. For example, the fifth TD in 20 TR

AFAIK, xpath support in jQuery is discarded, so I can't use xpath directly in jQuery?

+6
source share
3 answers

Firebug has a "css copy path" when right-clicking on an element. It can be used to create a selector.

+3
source

I'm not sure if you are asking the general abotu question converting XPath to a CSS selector, but I found this jquery post : choosing xpath or converting xpath to css? which can help. He recommends using the "eq" method to select an item by index. So the fifth TD in the 20th TR will be

$('tr').eq(20).find('td').eq(5) 
0
source

Source: https://habr.com/ru/post/898231/


All Articles