[英]checking if checkbox is checked or not using variable in javascript
我有一個存儲復選框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.