jquery实现图片跟随鼠标的实例

  

<强> jquery实现图片跟随鼠标的实例

  

,开发后台写页面困难的一比啊,想写个鼠标移动某连接右侧显示二维码,并跟随鼠标移动的功能,各种查资料,花了一小天终于搞出来了,代码的记下来,浪费了我这么多时间,记你一辈子,这个可以直接在W3School直接运行,可以根据某行显示某个特定的图片,自己定义就行

  

实现代码:
  

        & lt; html>   & lt; head>   & lt;脚本src=" http://libs.baidu.com/jquery/2.0.0/jquery.js "祝辞& lt;/script>   & lt;元http-equiv=? type”内容=" text/html;utf - 8字符集="/比;   & lt; title> jquery图片跟随鼠标& lt;/title>   & lt;脚本type=" text/javascript祝辞   函数hideImg (num) {   如果(num。className==? _name”) {   $ (' # 1 _erweima ') hide ();   如果(num}其他。className==? _name”) {   $ (' # 2 _erweima ') hide ();   }   }      函数showImg (num) {   var intX=window.event.clientX;   var intY=window.event.clientY;   如果(num.className==? _name”) {   $ (" # 1 _erweima”)。css(“左”,intX + 20 +“px”);   $ (" # 1 _erweima”)。css(“顶级”,intY + 10 +“px”);   $ (' # 1 _erweima '),告诉();   }else if (num.className==? _name”) {   $ (" # 2 _erweima”)。css(“左”,intX + 20 +“px”);   $ (" # 2 _erweima”)。css(“顶级”,intY + 10 +“px”);   $ (' # 2 _erweima '),告诉();   }   }   & lt;/script>   & lt;/head>   & lt; body>   & lt; table>   & lt; tr>   & lt; th>   & lt; a href=" https://www.baidu.com/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”类目标==? _name”“平等”的在我是百度,会跟随& lt;/a>   & lt;/th>   & lt;/tr>   & lt; tr>   & lt; th>   & lt; a href=" https://www.baidu.com/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”类目标==? _name”“平等”的在我是百度& lt;/a>   & lt;/th>   & lt;/tr>   & lt; tr>   & lt; th>   & lt; a href=" https://www.baidu.com/" rel=巴獠縩ofollow”rel=巴獠縩ofollow”rel=巴獠縩ofollow”类目标==? _name”“平等”的在我也是百度,也跟随& lt;/a>   & lt;/th>   & lt;/tr>   & lt; div id=? _erweima”比;   & lt; img src=" https://cache.yisu.com/upload/information/20200622/114/62494.png "/比;   & lt;/div>   & lt; div id=? _erweima”比;   & lt; img src=" https://cache.yisu.com/upload/information/20200622/114/62494.png "/比;   & lt;/div>   & lt;/table>   & lt;/body>   & lt;/html>   之前      

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

jquery实现图片跟随鼠标的实例