tags:

views:

181

answers:

2

i need to be able to select Xpaths in jquery.

selecting via CSS is difficult for form elements with name, value, type, not to mention traversing down the tree.

+2  A: 

jQuery supports basic Xpath by default.

http://docs.jquery.com/DOM/Traversing/Selectors#XPath%5FSelectors

EDIT- Kevin said it, it's only supported in 1.2, not anymore in 1.3. Try using advanced CSS selectors, attribute filters: http://docs.jquery.com/Selectors

Infinity
jQuery DID support XPATH in the past. It no longer does since v1.2+
Kevin Peno
+1 for re-wording
Kevin Peno
A: 

If you have the name of the element won't this work fine?

//by name
$('form input[name="foo"]')

//by id
$('#foo')

//by name in a specific form
$('form[name="bar"] input[name="foo"]')

//3rd option in a select
$('form[name="bar"] select[name="foo"] option:nth-child(3)')
scunliffe