jQuery Xpath选择器以选择ID包含"sometext"的元素 [英] jQuery Xpath selector to select an element which id contains 'sometext'
本文介绍了jQuery Xpath选择器以选择ID包含"sometext"的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在aspx页面中有一个listbox元素,其ID为attributesList.
I have a listbox element in aspx page which id is attributesList.
我想选择此元素以跟踪其更改事件,但是我无法直接选择其ID,因为asp.net在运行时会更改其ID.
I want to select this element to track its change event, but i cant directly select its id because asp.net changes its id on runtime.
其ID,attributesList更改为ctl00_adminPlaceHolder_attributesList.
its id, attributesList changes into ctl00_adminPlaceHolder_attributesList.
所以我要做的是使用包含" xpath表达式来选择元素.
so what i want to do is to use a "contains" xpath expression to select the element.
推荐答案
您将要改用,如下所示:
You'll want to instead use the "End with" attribute selector like so:
$("*[id$='attributesList']")
这篇关于jQuery Xpath选择器以选择ID包含"sometext"的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文