jquery js radio单选框取值和赋值

PHP代码,例如:

<input type="radio" name="sex" id="sex" value="0" >男
<input type="radio" name="sex" id="sex" value="1" >女

script代码,例如:
获取radio选中的值

var sex = $("#sex").val();

为radio赋值

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

猜你喜欢

转载自blog.csdn.net/Bel_Ami_n/article/details/82225711
今日推荐