Home > Article > Web Front-end > Tutorial on how to achieve magnification effect on jQuery mouse movement pictures
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='tooTip'><img src='" + this.href + "'></img><p>"; $("body").append(tooTip); $("#tooTip").css({ position: "absolute", 'top': (e.pageY + y) + "px", "left": (e.pageX + x) + "px" }).show("fast"); }).mouseout(function () { $("#tooTip").remove(); }).mousemove(function (e) { $("#tooTip").css({ position: "absolute", 'top': (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!