JavaScript
<body> <input type="checkbox" onmouseover="document.getElementById('div1').style.display = 'block'" onmouseout="document.getElementById('div1').style.display='none'"/> <div id = "div1"> for your information safety... </div> </body>
onmouseover,onmouseout
onmouseover = "document.getElementById('div1').style.display = 'block' ";
<body> <div id="div1" onmouseover="ToGreen()" onmouseout="ToRed()"> </div> </body> <script> function ToGreen() { var oDiv = document.getElementById('div1'); oDiv.style.width = '300px'; oDiv.style.height = '300px'; oDiv.style.background = 'green'; } function ToRed() { var oDiv = document.getElementById('div1'); oDiv.style.width = '200px'; oDiv.style.height = '200px'; oDiv.style.background = 'red'; } </script>
关联到了函数
onmouseover = "ToGreen ( ) ";
var oDiv = document.getElementById('div1');//获取节点
<body> <input id="btn1" type="button" value="全选" /><br> <input id="btn2" type="button" value="不选" /><br> <input id="btn3" type="button" value="反选" /><br> <div id="div1"> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> <input type="checkbox" /><br> </div> </body> <script> var i; window.onload = function () { var Btn1 = document.getElementById('btn1'); var Btn2 = document.getElementById('btn2'); var Div1 = document.getElementById('div1'); var cekb = Div1.getElementsByTagName('input'); var Btn3 = document.getElementById('btn3'); Btn1.onclick = function () { for (i = 0; i < cekb.length; i++) { cekb[i].checked = true; } } Btn2.onclick = function () { for (i = 0; i < cekb.length; i++) { cekb[i].checked = false; } } Btn3.onclick = function () { for (i = 0; i < cekb.length; i++) { if (cekb[i].checked == true) { cekb[i].checked = false; } else { cekb[i].checked = true; } } } } </script>
window.onload = function()
{
}
Btn1.onclick = function () {
for (i = 0; i < cekb.length; i++) {
cekb[i].checked = true;
}
}