开发者

Search all element IDs on a page using JQUERY

开发者 https://www.devze.com 2022-12-21 06:28 出处:网络
I have an ASP.NET 3.5 page which has multiple span elements with ID containing lblError. How can I get all the span elements whose开发者_如何学Python IDs contain lblError?$(\"span[id*=\'lblError\']\")

I have an ASP.NET 3.5 page which has multiple span elements with ID containing lblError. How can I get all the span elements whose开发者_如何学Python IDs contain lblError?


$("span[id*='lblError']")


Since you are probably doing this to get around the mangled names created when using server controls you can try a couple of ways.

This will find anything that has lblError in it at the end:

$("[id$='lblError']"); 

Also, if you know the server control name you can do the following in your aspx page which will find your exact control:

$("#'<%= lblError.ClientID %>'");
0

精彩评论

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