[英]checking if checkbox is checked or not using variable in javascript
I have a variable where I have stored my checkbox id's but while I am trying to check if the checkbox is selected or not, it's not working fine. 我有一个存储复选框ID的变量,但是当我尝试检查复选框是否选中时,它不能正常工作。
<script>
function check(){
var id = "checkbox1.0";
if($('#' + id).is(':checked')){alert("checked");}
}
</script>
<body>
<input type ="checkbox" id = "checkbox1.0">
<input type ="checkbox" id = "checkbox2.0" onclick="check()">
</body>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.