基于jquery实现一张图片点击鼠标放大再点缩小
jQuery 实现 基于 图片 鼠标 点击 一张 放大
2023-06-13 09:15:06 时间
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title></title>
<scriptsrc="jquery-1.8.3.min.js"></script>
<script>
varisopen=false;
varnewImg;
varw=200;//将图片宽度+200
varh=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;
functionmoveImg(left,top)
{
varoffset=$(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>
<divid="imgBox"style="width:100px;height:100px;background:#cccccc">
<imgid="img1"style="width:100px;height:100px;"alt=""src="photos/image1.jpg"/>
</div>
</div>
</body>
</html>
相关文章
- 利用Jquery Lazyload JS插件实现网页图片延迟加载
- 实现单页浮动导航效果的 jQuery 插件:Smint
- php实现jQuery扩展函数
- jQuery遍历json数组的实现代码
- 基于jquery的实现简单的表格中增加或删除下一行
- jquery下实现overlay遮罩层代码
- 修改jquery.lazyload.js实现页面延迟载入
- 基于jquery的复制网页内容到WORD的实现代码
- 基于Jquery的将DropDownlist的选中值赋给label的实现代码
- 基于jquery的从一个页面跳转到另一个页面的指定位置的实现代码(带平滑移动的效果)
- 基于jQuery实现的当离开页面时出现提示的实现代码
- 基于jquery实现的鼠标滑过按钮改变背景图片
- 基于Jquery实现的一个图片滚动切换
- 基于jQuery的简单九宫格实现代码
- js/jquery获取浏览器窗口可视区域高度和宽度以及滚动条高度实现代码
- jQuery实现form表单reset按钮重置清空表单功能
- Jquery写一个鼠标拖动效果实现原理与代码
- jquery卷帘效果实现代码(不同方向)
- 基于jquery实现点击左右按钮图片横向滚动
- 基于jquery实现后台左侧菜单点击上下滑动显示
- 基于jquery实现拆分姓名的方法(纯JS版)
- 基于jquery实现控制经纬度显示地图与卫星
- jQuery实现单行文字间歇向上滚动源代码
- jquery实现上下滚动效果示例代码
- 基于jquery的禁用右键、文本选择功能、复制按键的实现代码
- 基于MVC3方式实现下拉列表联动(JQuery)
- JQuery实现点击div以外的位置隐藏该div窗口
- 基于jquery实现的文字淡入淡出效果
- jquery实现省市select下拉框的替换(示例代码)
- 基于jquery实现的图片在各种分辨率下未知的容器内上下左右居中
- 两种方法基于jQuery实现IE浏览器兼容placeholder效果
- 基于jQuery实现的文字按钮表单特效整理