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.
質問
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");});