jquery动态控制checkbox选中状态 20
2个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>RunJS 演示代码</title>
<script>
$(document).ready(function(){
var str = "1,2,3";
$(str.split(",")).each(function (i,dom){
$(":checkbox[value='"+dom+"']").prop("checked",true);
$(":checkbox[id='"+dom+"']").prop("checked",true);
});
});
</script>
</head>
<body>
<label><input type="checkbox" />1</label>
<label><input type="checkbox" />2</label>
<label><input type="checkbox" />3</label>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>RunJS 演示代码</title>
<script>
$(document).ready(function(){
var str = "1,2,3";
$(str.split(",")).each(function (i,dom){
$(":checkbox[value='"+dom+"']").prop("checked",true);
$(":checkbox[id='"+dom+"']").prop("checked",true);
});
});
</script>
</head>
<body>
<label><input type="checkbox" />1</label>
<label><input type="checkbox" />2</label>
<label><input type="checkbox" />3</label>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询