jQuery Xpath selector to select an element which id contains 'sometext'

若如初见. 提交于 2019-12-13 05:38:38

问题


I have a listbox element in aspx page which id is attributesList.

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.

its id, attributesList changes into ctl00_adminPlaceHolder_attributesList.

so what i want to do is to use a "contains" xpath expression to select the element.


回答1:


You'll want to instead use the "End with" attribute selector like so:

$("*[id$='attributesList']")


来源:https://stackoverflow.com/questions/2075760/jquery-xpath-selector-to-select-an-element-which-id-contains-sometext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!