views:

49

answers:

2

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 IDs contain lblError?

+4  A: 
$("span[id*='lblError']")
xiechao
+1  A: 

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 %>'");
Kelsey