2

I'm trying to use XPath selectors with JQuery, but when I drop down to firebug (for example, in the linked page), I get syntax errors for the simplest XPath expressions:

>>> jQuery('//div')
"Syntax error, unrecognized expression: //div"

Am I doing something wrong, or are xpath selectors no longer supported?

1
  • What version of jQuery are you using? Commented Dec 5, 2011 at 14:38

2 Answers 2

2

xpath support was dropped in jquery 1.2. You can use xpath plugin if you really need it.

Sign up to request clarification or add additional context in comments.

2 Comments

Would be nice if the docs reflected this...
@Louis the page you linked has a big reddish box saying it's an old api documentation and linking to the new one that doesn't have xpath selectors.
1

XPath is not supported anymore. xpath functions not supported in jquery also talks about this.

To get all divs, use this:

>>> $('div')

or

>>> jQuery('div')

depending on your setup.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.