代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<script src="jquery-1.8.3.min.js"></script>
<script>
var isopen = false;
var newimg;
var w = 200; //将图片宽度+200
var h = 200; // 将图片高度 +200
$(document).ready(function(){
$("img").bind("click", function(){
newimg = this;
if (!isopen)
{
isopen = true;
$(this).width($(this).width() + w);
$(this).height($(this).height() + h);
moveimg(10, 10);
}
else
{
isopen = false;
$(this).width($(this).width() - w);
$(this).height($(this).height() - h);
moveimg(-10, -10);
}
});
});
//移位
i = 0;
function moveimg(left,top)
{
var offset = $(newimg).offset();
$(newimg).offset({ top: offset.top + top, left: offset.left + left});
if (i == 10)
{
i =0;
return;
}
settimeout("moveimg("+left+","+top+")", 10);
i++;
}
</script>
</head>
<body>
<p id="imgbox" style="width:100px; height:100px; background:#cccccc">
<img id="img1" style="width:100px;height:100px; " alt="" src="photos/image1.jpg" />
</p>
</p>
</body>
</html>
如对本文有疑问, 点击进行留言回复!!
Parallels Desktop v15.1.4-47270 商业版下载 Mac安装Windows首选虚拟机
关于LPC824Lite开发板下载程序时提示"Invalid ROM Table"
MySQL 5.7 关于 JSON 类型的子集Key/Value获取方法分享
javascript从入门到跑路-----小文的js学习笔记(19)------- js的垃圾回收机制
网友评论