有点没搞明白创建的节点为什么不能多次使用,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
position: relative;
z-index: -1;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<input type="button" value="加粗画笔">
<input type="button" value="画笔变细">
<input type="button" value="红色">
<script>
let oDiv = document.createElement("div");
document.onmousedown = function (eve) {
//let oDiv = document.createElement("div");
let wd = oDiv.style.width = 16 + "px";
let ht = oDiv.style.height = 16 + 'px';
oDiv.style.background = 'black';
oDiv.style.position = "absolute";
oDiv.style.borderRadius = 50 + "%";
oDiv.style.zIndex = -1;
let e = eve || window.event;
oDiv.style.left = e.pageX + "px";
oDiv.style.top = e.pageY + "px";
document.body.appendChild(oDiv);
}
</script>
</body>
</html>