按下鼠标拖拽绘画
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
html,body{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
</body>
</html>
<script>
document.onmousedown = function(evt){
document.body.onmousemove=function(evt){
var d=document.createElement("div");
var e = evt ;
d.style.width="10px";
d.style.height="10px";
d.style.background=colorwehe();
d.style.borderRadius="50%";
d.style.position="absolute";
document.body.appendChild(d);
d.style.left = e.clientX + "px";
d.style.top = e.clientY + "px";
console.log("dsfd");
}
}
function colorwehe() {
var a = Math.floor(Math.random() *256);
b = Math.floor(Math.random() * 256);
c = Math.floor(Math.random() * 256)
return "rgb(" + a + "," + b + "," + c +")"
}
document.onmouseup = function(evt){
document.body.onmousemove = null
}
</script>