您的位置:首页 > 其它

点击图片随机移动位置

2013-06-25 22:41 253 查看
<html>

<head>

<script>

//onclick 事件

//改变它的CSS的left和top的值

function clickfun(){

document.getElementById("imgId").style.left=Math.random()*500;
//点击图片随机改变 left
位置

document.getElementById("imgId").style.top=Math.random()*400; //点击图片随机改变
top 位置

}

//onmouseover 把当前的IMG的链接改为另一张图片

function mOver(){

document.getElementById("imgId").src="201301.jpg";

}

//onmouseout 鼠标移出的时候,把图片链接改回原图

function mOut(){

document.getElementById("imgId").src="201302.jpg";

}

</script>

</head>

<body>

<!--
cursor:pointer:鼠标移动到图片上时变为手型 -->


<img src="201302.jpg" id="imgId" style="position:absolute;width:50;height:50;top:100;left:100; cursor:pointer;"

onclick="clickfun()" onmouseover="mOver()" onmouseout="mOut()">

</body>

</html>

<!-- 用到的图片 -->



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