how to find control using name attribute in jquery if the control is a server side control
i have a radio button group and want to find the attribute value of which one is checked
i was using the below code which was working fine previously but since i have made the control as a server side control(.net) it is rendering the name attribute differently.
var id = $("input[name=thumbGroup]:checked").attr('value');
rendered html
<input id="ctl00_ctl00_piSection_rdUseThubImg" type="radio" name="ctl00$ctl00$piSection$thumbGroup" va开发者_开发问答lue="0">
Please advice how can i get the value attribute from the above markup using jquery
I would ask what the html structure of the page is..
if you can narrow your filter to a specific section of the page then you can get the checked inputs without knowing the name..
for example lets say the structure is this:
<div class="somediv">
<div class="formsection1">
</div>
<div class="formsection2">
<input id="ctl00_ctl00_piSection_rdUseThubImg" type="radio" name="ctl00$ctl00$piSection$thumbGroup" value="0">
</div>
</div>
Then you could do a selector like this:
$(".formsection2 input[type=radio]:checked")
Something like that should do the trick.
You can use ClientID property of a control to get the exact id that get rendered.
So for eg.. if you have a radiobutton named rdUseThubImg, you can use rdUseThubImg.ClientID in the mark up to get its corresponding client side id which equals to ctl00_ctl00_piSection_rdUseThubImg
so in the javascript you can use $("<%= rdUseThubImg.ClientID %>")
more on the client id property.. http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid(v=VS.85).aspx
精彩评论