<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../picture/jquery-2.0.3.min.js"></script>
</head>
<body>
<input type="radio" class="options" value="1">是
<input type="radio" class="options" value="0">否
</body>
<script type="text/javascript">
//获取radio对象
var radioObj = $('.options');
//模拟后台回传数据
var data = 1;
//for循环遍历radio对象,比较radio对象中的value和data是否一致
//如果一致就设置状态为选中,然后跳出循环,并将其他按钮的状态设置为false
for(var i=0; i<radioObj.length; i++){
if(radioObj[i].value == data){
radioObj[i].checked = true;
break;
}
radioObj[i].checked = false;
}
</script>
</html>