Home > Web Front-end > JS Tutorial > body text

Tutorial on how to achieve magnification effect on jQuery mouse movement pictures

小云云
Release: 2018-01-06 10:39:01
Original
1879 people have browsed it

This article mainly introduces the jQuery mouse movement to achieve the magnification effect on pictures. Friends who need it can refer to it. I hope it can help everyone.

First of all, there must be pictures on the interface. The following is the picture


<img id="big-circle" src="images/pic2.jpg" alt=""/>其次在script代码段中加入如下代码,进行适量修改即可
$(document).ready(function () {
     var x = 10;
     var y = 20;
     $("#big-circle").mouseover(function (e) {
       var tooTip = "<p id=&#39;tooTip&#39;><img src=&#39;" + this.href + "&#39;></img><p>";
       $("body").append(tooTip);
       $("#tooTip").css({ position: "absolute",
         &#39;top&#39;: (e.pageY + y) + "px", "left": (e.pageX + x) + "px"
       }).show("fast");
     }).mouseout(function () {
             $("#tooTip").remove();
     }).mousemove(function (e) {
       $("#tooTip").css({ position: "absolute",
         &#39;top&#39;: (e.pageY + y) + "px", "left": (e.pageX + x) + "px"
       });
     });
   });
Copy after login

Related recommendations:

JS imitation Alipay input input display Digital magnifying glass

JavaScript imitation of Taobao to achieve magnifying glass effect

JS to achieve e-commerce touch enlargement effect

The above is the detailed content of Tutorial on how to achieve magnification effect on jQuery mouse movement pictures. For more information, please follow other related articles on the PHP Chinese website!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template