全选和反选
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
function change(){
var quan=document.getElementsByClassName("check")
for(var i=0;i<quan.length;i++){
var checknode = quan[i];
if(checknode.checked == true){
checknode.checked = false;
}else{
checknode.checked = true;
}
}
}
</script>
</head>
<body>
<input type="checkbox" onclick="change()"/>全选
<h2>你的爱好是</h2>
<ul>
<li><input type="checkbox" class="check"/>唱</li>
<li><input type="checkbox" class="check"/>跳</li>
<li><input type="checkbox" class="check"/>玩游戏</li>
<li><input type="checkbox" class="check"/>刷抖音</li>
<li><input type="checkbox" class="check"/>rap</li>
<li><input type="checkbox" class="check"/>打台球</li>
<li><input type="checkbox" class="check"/>篮球</li>
</ul>
</body>
</html>
移动的div
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#d1{
width: 100px;
height: 100px;
background-color: aqua;
position: absolute;
cursor: move;
}
</style>
</head>
<body>
<div id="d1"></div>
<script type="text/javascript">
var kuai1 = document.getElementById("d1");
kuai1.onmousedown = function(e){
var w = e.clientX - kuai1.offsetLeft;
var h = e.clientY - kuai1.offsetTop;
document.onmousemove = function(ev){
kuai1.style.top = (ev.clientY - h) + "px";
kuai1.style.left = (ev.clientX - w)+ "px";
}
}
kuai1.onmouseup = function(){
document.onmousemove = null;
}
</script>
</body>
</html>