jquery實(shí)現(xiàn)圖片跟隨鼠標(biāo)的實(shí)例
jquery實(shí)現(xiàn)圖片跟隨鼠標(biāo)的實(shí)例
開發(fā)后臺寫頁面困難的一比啊,想寫個鼠標(biāo)移動某連接右側(cè)顯示二維碼,并跟隨鼠標(biāo)移動的功能,各種查資料,花了一小天終于搞出來了,代碼的記下來,浪費(fèi)了我這么多時間,記你一輩子,這個可以直接在W3School直接運(yùn)行,可以根據(jù)某行顯示某個特定的圖片,自己定義就行
實(shí)現(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圖片跟隨鼠標(biāo)</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獲取所有標(biāo)簽的實(shí)現(xiàn)代碼
在前端開發(fā)中,使用jQuery能夠方便地操作DOM元素,有時候我們需要獲取頁面上所有的HTML標(biāo)簽,可以通過jQuery來實(shí)現(xiàn),本文將介紹如何使用jQuery獲取所有的標(biāo)簽,并展示一個簡單的示例代碼,需要的朋友可以參考下2024-09-09jQuery textarea的長度進(jìn)行驗(yàn)證
Textarea 控件不能使用form validate.js 進(jìn)行判斷.2009-05-05jQuery實(shí)現(xiàn)的上傳圖片本地預(yù)覽效果簡單示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的上傳圖片本地預(yù)覽效果,結(jié)合實(shí)例形式分析了jQuery上傳圖片本地預(yù)覽所涉及的相關(guān)頁面元素屬性動態(tài)操作實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-03-03easyui取消表單實(shí)時驗(yàn)證,提交時統(tǒng)一驗(yàn)證的簡單實(shí)例
下面小編就為大家?guī)硪黄猠asyui取消表單實(shí)時驗(yàn)證,提交時統(tǒng)一驗(yàn)證的簡單實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11jQuery EasyUi實(shí)戰(zhàn)教程之布局篇
jQuery EasyUI Layout是一種基于jQuery的布局框架,今天初次使用Jquery EasyUi,簡單的做了個布局頁面感覺還不錯,特此分享腳本之家平臺供大家學(xué)習(xí)2016-01-01jquery操作select option 的代碼小結(jié)
jquery操作select option 的代碼小結(jié),需要的朋友可以參考下。2011-06-06jquery實(shí)現(xiàn)仿Flash的橫向滑動菜單效果代碼
這篇文章主要介紹了jquery實(shí)現(xiàn)仿Flash的橫向滑動菜單效果代碼,可實(shí)現(xiàn)滑塊跟隨鼠標(biāo)滑動效果的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09JQuery實(shí)現(xiàn)列表中復(fù)選框全選反選功能封裝(推薦)
在做列表時經(jīng)常會遇到全選,反選進(jìn)行批量處理問題。通過本文給大家介紹JQuery實(shí)現(xiàn)列表中復(fù)選框全選反選功能封裝,對jq復(fù)選框全選反選功能感興趣的朋友一起看看吧2016-11-11