Home  >  Article  >  Web Front-end  >  Tutorial on how to achieve magnification effect on jQuery mouse movement pictures

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

小云云
小云云Original
2018-01-06 10:39:011836browse

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"
       });
     });
   });

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!

Statement:
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