문제

How to select a list of asp labels within a div?

<div id="myDiv"> <asp:Label ID="myLabel".../> <asp:Label ID="myLabel".../> </div>

This Jquery code does not work.

$("#myDiv label").each(function(){ alert("show this msg");});

Any assistance will be appreciated.

도움이 되었습니까?

해결책

Try this:

$("#myDiv span[id*=myLabel]").each(function(){ alert("show this msg");});

Since, a asp:Label is rendered as span in HTML.

Also, please give some unique ID to the asp labels like myLabel1, myLabel2, etc.

다른 팁

Try this:
u can iterate through all lables inside #mydiv.use ^ selector which check the starting string

$("#myDiv span[id^=myLabel]").each(function(){ alert("show this msg");});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top