您的位置:首页 > Web前端 > JavaScript

js模拟画笔效果

2008-10-05 00:00 316 查看
模拟画笔效果

var ballW = 10,ballH = 10;
document.onmousemove = function(evt){
var evt=evt?evt:window.event;
var posX=evt.clientX;
var posY=evt.clientY;
var newDiv=document.createElement("div");
document.body.appendChild(newDiv);
newDiv.style.width=ballW+"px";
newDiv.style.height=ballH+"px";
newDiv.style.backgroundColor="red";
newDiv.style.position="absolute";
newDiv.style.left=posX-(ballW/2)+"px";
newDiv.style.top=posY-(ballH/2)+"px";

}






[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: