html的checkbox无法勾选
html的checkbox无法勾选
index.html
<div id="wrap">
<input id="check" type="checkbox" value="" />
</div>
index.js:
var wrap= document.getElementById("wrap");
wrap.οnclick=function(){
return false;
}
这样会出现checkbox无法点击的情况,原因是外层父元素的onclick被设置成实现了,导致子元素的
onclick的失效
index.js:
var wrap= document.getElementById("wrap");
wrap.οnclick=function(){
return false;
}
var check=document.getElementById("check");
check.οnclick=function(){
return true;
}
这样checkBox就可以点击了