js radio单选框使用总结

<script type="text/javascript">
$(document).ready(function(){
        $("input[name=sex][value=1]").attr("checked",true);
});
</script>

您的性别:
<input type="radio" name="sex" value="1" />男
<input type="radio" name="sex" value="0" />女


name的值来判断是哪一类

选中用如下方法

$(this).attr("checked", true);
$(this).prop("checked", true);


prop也可以设置属性值

设置无效

$(this).prop("disabled", "disabled");


设置有效

$(this).removeAttr("disabled");


获取选中值

$('#wrap input[name="payMethod"]:checked ').val();


猜你喜欢

转载自forlan.iteye.com/blog/2285678