<html>
<head>
<title>test</title>
</head>
<body>
<img src="http://bbs.51js.com/images/logo.gif" style="position:absolute" unselectable="on" id="js51" />
<script type="text/javascript">
function Move(o, e){
this.v = !this.v ? true : false;
if(this.v){
o.style.filter = 'Alpha(opacity=50)';
o.style.opacity = '0.5';
var e = window.event || e;
var _xy = o.offsetTop - e.clientY;
var _xx = o.offsetLeft - e.clientX;
if(e.preventDefault){
e.preventDefault();
}
document.onmousemove = function(e){
var e = window.event || e;
o.style.top = _xy + e.clientY + "px";
o.style.left = _xx + e.clientX + "px";
}
}
else{
o.style.filter = o.style.opacity = '';
document.onmousemove = null;
}
}
document.getElementById("js51").onclick = function(event){
Move(this, event);
}
</script>
</body>
</html>
另类拖动效果
最新推荐文章于 2024-08-05 15:16:48 发布