jquery實現(xiàn)圖片跟隨鼠標的實例
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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
jQuery實現(xiàn)的上傳圖片本地預(yù)覽效果簡單示例
這篇文章主要介紹了jQuery實現(xiàn)的上傳圖片本地預(yù)覽效果,結(jié)合實例形式分析了jQuery上傳圖片本地預(yù)覽所涉及的相關(guān)頁面元素屬性動態(tài)操作實現(xiàn)技巧,需要的朋友可以參考下2018-03-03easyui取消表單實時驗證,提交時統(tǒng)一驗證的簡單實例
下面小編就為大家?guī)硪黄猠asyui取消表單實時驗證,提交時統(tǒng)一驗證的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11jquery操作select option 的代碼小結(jié)
jquery操作select option 的代碼小結(jié),需要的朋友可以參考下。2011-06-06jquery實現(xiàn)仿Flash的橫向滑動菜單效果代碼
這篇文章主要介紹了jquery實現(xiàn)仿Flash的橫向滑動菜單效果代碼,可實現(xiàn)滑塊跟隨鼠標滑動效果的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09JQuery實現(xiàn)列表中復(fù)選框全選反選功能封裝(推薦)
在做列表時經(jīng)常會遇到全選,反選進行批量處理問題。通過本文給大家介紹JQuery實現(xiàn)列表中復(fù)選框全選反選功能封裝,對jq復(fù)選框全選反選功能感興趣的朋友一起看看吧2016-11-11