jQuery實現鏈接的title快速出現的方法
具體代碼如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>login</title>
<script type="text/javascript" src="jquery.min.js"></script>
</head>
<style>
body{
margin:0;
padding:40px;
background:#fff;
font:80% Arial, Helvetica, sans-serif;
color:#555;
line-height:180%;
}
p{
clear:both;
margin:0;
padding:.5em 0;
}
#tooltip{
position:absolute;
border:1px solid #333;
background:#f7f5d1;
padding:1px;
color:#333;
display:none;
}
</style>
<body>
<p><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" title="這是我的超鏈接提示1">提示1</a></p>
<p><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" title="這是我的超鏈接提示2">提示2</a></p>
<p><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" title="這是自帶提示1">自帶提示1</a></p>
<p><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" title="這是自帶提示2">自帶提示2</a></p>
<script>
$(function () {
$("a.tooltip").mouseover(function(e){
var tooltip="<div id='tooltip'>"+this.title+"</div>";
$("body").append(tooltip);
$("#tooltip")
.css({
"top":e.pageY+"px",
"left":e.pageX+"px"
}).show("fast");
}).mouseout(function(){
$("#tooltip").remove();
});
});
</script>
</body>
</html>
jQuery 事件 - pageY 屬性
顯示鼠標指針的位置
show() 方法
顯示所有隱藏的 <p> 元素:
注意:show() 適用于通過 jQuery 方法和 CSS 中 display:none 隱藏的元素(不適用于通過 visibility:hidden 隱藏的元素)。
JQuery中這個function(e)那個e是什么意思?
回答一:e是事件,在firefox中只能在事件現場使用window.event,所以只有把event傳給函數使用。為了兼容FF和其它瀏覽器,一般會在函數里重新給e賦值:
e = window.event || e;
也就是說,如果window.event存在,則該瀏覽器支持直接使用window.event,否在就是不支持,不支持就使用傳進來的e。
回答二:事件對象event 和我們普通寫的 <input type="text" onclick = "aaa(event)">中的這個event一模一樣
jquery里邊的事件綁定函數中的參數e 都是在框架中給處理好了的 兼容各種瀏覽器。
以上所述是小編給大家介紹的jQuery實現鏈接的title快速出現,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
相關文章
利用jQuery實現CheckBox全選/全不選/反選的簡單代碼
下面小編就為大家?guī)硪黄胘Query實現CheckBox全選/全不選/反選的簡單代碼。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
詳談jQuery操縱DOM元素屬性 attr()和removeAtrr()方法
這篇文章主要詳細介紹了jQuery操縱DOM元素屬性 attr()和removeAtrr()方法,非常的全面細致,在這里推薦給小伙伴們。2015-01-01
jquery+ajax實現省市區(qū)三級聯動(封裝和不封裝兩種方式)
這篇文章主要為大家詳細介紹了jquery+ajax實現省市區(qū)三級聯動的相關代碼,包括封裝和不封裝兩種方式,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
jQuery Datatables 動態(tài)列+跨列合并實現代碼
這篇文章主要介紹了jQuery Datatables 動態(tài)列+跨列合并實現代碼,需要的朋友可以參考下2020-01-01

