开发者

need xpath selector plugin for jquery

开发者 https://www.devze.com 2022-12-09 18:17 出处:网络
i need to be able to select Xpaths in jquery. selecting via CSS is difficult for form elements with name, value,开发者_如何学C type, not to mention traversing down the tree.jQuery supports basic Xpat

i need to be able to select Xpaths in jquery.

selecting via CSS is difficult for form elements with name, value,开发者_如何学C type, not to mention traversing down the tree.


jQuery supports basic Xpath by default.

http://docs.jquery.com/DOM/Traversing/Selectors#XPath_Selectors

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


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)')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号