<body>
<p id="f">我们都是好孩子</p>
<input type="checkbox" name="a" id="a">a
<input type="checkbox" name="b">b
<script type="text/javascript">
if(document.getElementById("a").checked==true){
alert("hi");
}
</script>
</body>为何选中复选框,又没弹出东西呢?
<p id="f">我们都是好孩子</p>
<input type="checkbox" name="a" id="a">a
<input type="checkbox" name="b">b
<script type="text/javascript">
if(document.getElementById("a").checked==true){
alert("hi");
}
</script>
</body>为何选中复选框,又没弹出东西呢?
<p id="f">我们都是好孩子</p>
<input type="checkbox" name="a" id="a" onclick="test();">a
<input type="checkbox" name="b">b
<script type="text/javascript">
function test(){
if(document.getElementById("a").checked==true){
alert("hi");
}
}
</script>
</body>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<p id="f">我们都是好孩子</p>
<input type="checkbox" name="a" id="a">a
<input type="checkbox" name="b">b
<script type="text/javascript">
document.getElementById("a").onclick = function(){
if(this.checked){
alert('a')
}
};
</script>
</body>
</html>