<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
function change(){
var checkdocs = document.getElementsByClassName("cll_check");
for(var i = 0;i<checkdocs.length;i++){
var checkNode = checkdocs[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="cll_check"/>看书</li>
<li><input type="checkbox" class="cll_check"/>看电影</li>
<li><input type="checkbox" class="cll_check"/>玩游戏</li>
<li><input type="checkbox" class="cll_check"/>刷抖音</li>
<li><input type="checkbox" class="cll_check"/>泡芙</li>
<li><input type="checkbox" class="cll_check"/>打台球</li>
<li><input type="checkbox" class="cll_check"/>打麻将</li>
</ul>
</body>
</html>
<!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 d1Node = document.getElementById("d1");
d1Node.onmousedown = function(e){
var w = e.clientX - d1Node.offsetLeft; //clientX===>可视区 X 坐标,距离左边框的位置
var h = e.clientY - d1Node.offsetTop; //clientY===>可视区 Y 坐标,距离上边框的位置
document.onmousemove = function(ev){
d1Node.style.top = (ev.clientY - h) + "px";
d1Node.style.left = (ev.clientX - w)+ "px";
}
}
d1Node.onmouseup = function(){
document.onmousemove = null;
}