JQ一个点击事件控制另外两个radio框切换选中问题
<div id= "tab">
<input name="cooperation" type="radio" value="1" checked/>自营
<input name="cooperation" type="radio" value="2" />第三方
</div>
//这里传入的参数 res.cooperation 是我原本代码里面的ajax请求的数据,我是要根据这个作条件渲染select
$("#tab).on(function(res.cooperation){
if(res.cooperation == 1){
//元素固有属性建议使用prop(),attr()是我心里的痛
$('input[name="cooperation"][value="2"]').removeAttr("checked")
$('input[name="cooperation"][value="1"]').prop("checked",true)
} else {
$('input[name="cooperation"][value="1"]').removeAttr("checked")
$('input[name="cooperation"][value="2"]').prop("checked",true)
}
})