您的位置:首页 > 其它

事件原理

2016-05-02 13:45 316 查看
<body>

<input type="text" id="y1" value=""/><br/><br/>

<input type="button" id="b1"value=""/><br/><br/>

<div id="l1" style="width:300px;position: absolute; left: 20px;top: 100px; height:500px;background:green;overflow: hidden;"></div>

</body>

<script type="text/javascript">

var a = document.getElementById("y1");

var b = document.getElementById("b1");

var c = document.getElementById("l1");

var sum = "";

b.onclick=function(){

sum = sum + a.value;

document.getElementById("l1").innerHTML= sum;

document.getElementById("y1").value="";

}

c.onmousedown=function(e){

document.onmousemove = function (e){

c.style.top = e.clientY+5+"px";

c.style.left = e.clientX+"px";

}

}

c.onmouseup=function(e){

document.onmousemove = null;

}

</script>








</body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: