html文件:
<html>
<body>
<label>
<input type="checkbox" name="postcheckbox" />
demo checkbox
</label>
</body>
</html>
我想获得控制器中复选框状态改变的值
使用Js
var checkbox = document.querySelector("input[name=postcheckbox]");
checkbox.addEventListener('change', function() {
if (this.checked) {
console.log("Checkbox is checked..");
//pass to model
} else {
console.log("Checkbox is not checked..");
//pass to model
}
});