点鼠标,弹出一个层,并且跟随鼠标,如何作啊?---在线
我希望在一个连接上点击鼠标后,弹出一个层,并且这个层的位置是根据鼠标的位置走的。
如何实现阿?
[解决办法]
<script>
function flow(){
x = event.x;
y = event.y;
var obj = document.getElementById( "pad ");
obj.style.left = x;
obj.style.top = y;
}
function init(){
var obj = document.getElementById( "pad ");
document.body.onmousemove = flow;
obj.style.visibility = "visible ";
}
</script>
<input type= "button " onclick= "init(); ">
<div id= "pad " style= "position:absolute;left:0px;top:0px;width:100px;height:100px;background-color:red;visibility:hidden; "> </div>