jquery實(shí)現(xiàn)圖片跟隨鼠標(biāo)的實(shí)例
jquery實(shí)現(xiàn)圖片跟隨鼠標(biāo)的實(shí)例
開發(fā)后臺(tái)寫頁(yè)面困難的一比啊,想寫個(gè)鼠標(biāo)移動(dòng)某連接右側(cè)顯示二維碼,并跟隨鼠標(biāo)移動(dòng)的功能,各種查資料,花了一小天終于搞出來(lái)了,代碼的記下來(lái),浪費(fèi)了我這么多時(shí)間,記你一輩子,這個(gè)可以直接在W3School直接運(yùn)行,可以根據(jù)某行顯示某個(gè)特定的圖片,自己定義就行
實(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;">我是百度,會(huì)跟隨</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>
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
CSS+jQuery實(shí)現(xiàn)簡(jiǎn)單的折疊菜單
這篇文章主要介紹了CSS+jQuery實(shí)現(xiàn)簡(jiǎn)單的折疊菜單的代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2016-12-12
jquery實(shí)現(xiàn)界面無(wú)刷新加載登陸注冊(cè)
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)界面無(wú)刷新加載登陸注冊(cè),具有一定的參考價(jià)值,感興趣的朋友可以參考一下2016-07-07
jQuery實(shí)現(xiàn)最簡(jiǎn)單實(shí)用的分秒倒計(jì)時(shí)
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)最簡(jiǎn)單實(shí)用的分秒倒計(jì)時(shí),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
jQuery層動(dòng)畫定位滑動(dòng)效果的方法
這篇文章主要介紹了jQuery層動(dòng)畫定位滑動(dòng)效果的方法,涉及jQuery中animate方法的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-04-04
jQuery對(duì)于顯示和隱藏等常用狀態(tài)的判斷方法
這篇文章主要介紹了jQuery對(duì)于顯示和隱藏等常用狀態(tài)的判斷方法,給出了兩種較為常用的判斷方法,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-12-12

