Kumar
Kumar

Reputation: 2863

Search all element IDs on a page using JQUERY

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?

Upvotes: 0

Views: 153

Answers (2)

Kelsey
Kelsey

Reputation: 47726

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

Upvotes: 1

xiechao
xiechao

Reputation: 2361

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

Upvotes: 4

Related Questions