转自:https://blog.csdn.net/dongfengkuayue/article/details/50352937

取radio的值:

js代码

  $("input[name='radioName'][checked]").val();

给radio 赋值, 选中值为2的radio:

js代码:

  $("input[name='radioName'][value=2]").attr("checked",true);

<script type="text/javascript">
$(document).ready(function(){
var type=<%=(String)request.getAttribute("specialType")%>;
if(type==0){
$("input[name='specialType'][value=0]").attr("checked",true);
}else{
$("input[name='specialType'][value=1]").attr("checked",true);
}
});
</script>
<table>
<tr>
<td class="td_label">Special Type</td>
<td>
<label for="whiteList">Whitelist</label>
<input type="radio" id="specialType1" name="specialType" value="0"/>
<label for="blackList">Blacklist</label>
<input type="radio" id="specialType2" name="specialType" value="1" />
</td>
</tr>
</table>

另:https://blog.csdn.net/zbyluxzing/article/details/46965915

04-17 03:41
查看更多