Home > Web Front-end > JS Tutorial > Implementing a picture based on jquery by clicking the mouse to zoom in and then zooming out_jquery

Implementing a picture based on jquery by clicking the mouse to zoom in and then zooming out_jquery

WBOY
Release: 2016-05-16 17:21:09
Original
1513 people have browsed it
复制代码 代码如下:







<script> <br>var isopen = false; <br>var newImg; <br>var w = 200; //将图片宽度 200 <br>var h = 200; // 将图片高度 200 <br>$(document).ready(function(){ <br>$("img").bind("click", function(){ <br>newImg = this; <br>if (!isopen) <br>{ <br>isopen = true; <br>$(this).width($(this).width() w); <br>$(this).height($(this).height() h); <br>moveImg(10, 10); <br>} <br>else <br>{ <br>isopen = false; <br>$(this).width($(this).width() - w); <br>$(this).height($(this).height() - h); <br>moveImg(-10, -10); <br>} <br><br>}); <br>}); <br>//移位 <br>i = 0; <br>function moveImg(left,top) <br>{ <br>var offset = $(newImg).offset(); <br>$(newImg).offset({ top: offset.top top, left: offset.left left}); <br>if (i == 10) <br>{ <br>i =0; <br>return; <br>} <br>setTimeout("moveImg(" left "," top ")", 10); <br>i ; <br>} <br></script>









Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template