国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jquery實現(xiàn)圖片跟隨鼠標的實例

2019-11-19 15:09:23
字體:
供稿:網(wǎng)友

jquery實現(xiàn)圖片跟隨鼠標的實例

 開發(fā)后臺寫頁面困難的一比啊,想寫個鼠標移動某連接右側(cè)顯示二維碼,并跟隨鼠標移動的功能,各種查資料,花了一小天終于搞出來了,代碼的記下來,浪費了我這么多時間,記你一輩子,這個可以直接在W3School直接運行,可以根據(jù)某行顯示某個特定的圖片,自己定義就行

實現(xiàn)代碼:

<html> <head> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   <title>jquery圖片跟隨鼠標</title>   <script type="text/javascript">     function hideImg(num){       if(num.className == "1_name"){         $('#1_erweima').hide();       }else if(num.className == "2_name"){         $('#2_erweima').hide();       }     }      function showImg(num) {       var intX = window.event.clientX;       var intY = window.event.clientY;       if (num.className == "1_name") {         $('#1_erweima').css("left", intX + 20 + "px");         $('#1_erweima').css("top", intY + 10 + "px");         $('#1_erweima').show();       } else if (num.className == "2_name") {         $('#2_erweima').css("left", intX + 20 + "px");         $('#2_erweima').css("top", intY + 10 + "px");         $('#2_erweima').show();       }     }   </script> </head> <body> <table>   <tr>     <th>       <a  rel="external nofollow" rel="external nofollow" rel="external nofollow" class="1_name" target="_blank" onmouseout="hideImg(this)" onmousemove="showImg(this)" onmouseover="showImg(this)" style="color: #1192cc;">我是百度,會跟隨</a>     </th>   </tr>   <tr>     <th>       <a  rel="external nofollow" rel="external nofollow" rel="external nofollow" class="1_name" target="_blank" style="color: #1192cc;">我是百度</a>     </th>   </tr>   <tr>     <th>       <a  rel="external nofollow" rel="external nofollow" rel="external nofollow" class="2_name" target="_blank" onmouseout="hideImg(this)" onmousemove="showImg(this)" onmouseover="showImg(this)" style="color: #1192cc;">我也是百度,也跟隨</a>     </th>   </tr>   <div id="1_erweima" style="display:none;right:20;position:absolute;">     <img src="https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png" />   </div>   <div id="2_erweima" style="display:none;right:20;position:absolute;">     <img src="https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png" />   </div> </table> </body> </html> 

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 台前县| 霍林郭勒市| 东明县| 甘南县| 芮城县| 苏州市| 抚宁县| 丹巴县| 莱州市| 阳山县| 清苑县| 东宁县| 华容县| 长武县| 吐鲁番市| 咸宁市| 重庆市| 吉木乃县| 汉中市| 开远市| 响水县| 连云港市| 本溪| 社旗县| 涿州市| 威远县| 通化市| 雷州市| 城市| 离岛区| 康平县| 城口县| 高陵县| 宁远县| 嘉祥县| 北川| 和龙市| 鹿邑县| 旬阳县| 南开区| 太仆寺旗|