Jquery: choosing xpath or converting xpath to css?

I need to choose based on xpath or convert xpath to css.

there is a plugin or built-in function.

ex. $('/html/body/div/a[4]').each ....

+5
source share
1 answer

Not all xpath expressions can be translated to CSS-like selectors or do not work efficiently. You can use the :eq selector to access items by index, but it is recommended that you use the eq method instead. This will be equivalent to xpath in your example:

 $('html > body > div > a').eq(3).each( ... 
+3
source

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


All Articles