欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于jquery的自定義鼠標(biāo)提示效果 jquery.toolTip

 更新時(shí)間:2010年11月14日 22:34:27   作者:  
看到其它網(wǎng)站A標(biāo)簽title效果,心里癢癢,就想也用到自己網(wǎng)站上。 正好在學(xué)jquery 插件擴(kuò)展,就參照前輩代碼,自己動(dòng)手寫了一個(gè)
IE下效果

Firefox或其它瀏覽器效果


代碼

復(fù)制代碼 代碼如下:

//版權(quán) 酷車中國 www.kuchechina.com
//作者 逐月 zhuyue.cnblogs.com
//演示 http://www.kuchechina.com/carstools/Default.aspx
jQuery.fn.toolTip = function() {
this.unbind().hover(
function(e) {
this.t = this.title;
this.title = '';
$('body').append( '<p id="p_toolTip" style="display:none; max-width:320px;text-align:left;"><img id="img_toolTip_Arrow" src="images/arrow.gif" />' + this.t + '</p>' );
var tip = $('p#p_toolTip').css({ "position": "absolute", "padding": "10px 5px 5px 10px", "left": "5px", "font-size": "14px", "background-color": "white", "border": "1px solid #a6c9e2","line-height":"160%", "-moz-border-radius": "5px", "-webkit-border-radius": "5px", "z-index": "9999"});
var target = $(this);
var position = target.position();
this.top = (position.top - 8); this.left = (position.left + target.width() + 5);
$('p#p_toolTip #img_toolTip_Arrow').css({"position": "absolute", "top": "8px", "left": "-6px" });
tip.css({"top": this.top+"px","left":this.left+"px"});
tip.fadeIn("slow");
},
function() {
this.title = this.t;
$("p#p_toolTip").fadeOut("slow").remove();
}
);
};

使用方法:
復(fù)制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function(){
$("#tootlsMain img[title]").toolTip();
});
</script>

可以利用jquery 選擇器,選擇帶title屬性的標(biāo)簽,當(dāng)然可以適當(dāng)?shù)男薷拇a使適用帶alt屬性標(biāo)簽。
title屬性支持簡單html標(biāo)簽。如<br/>等。注意引號(hào)的使用
實(shí)現(xiàn)原理:
利用標(biāo)簽title屬性,使hover事件取代默認(rèn)鼠標(biāo)事件,顯示浮動(dòng)層。this.unbind().hover 就是這句代碼。jquery幫我們做好很多事情。堆積我們的現(xiàn)實(shí)代碼就行。
程序員,文筆一般希望您能看懂。

代碼下載

相關(guān)文章

最新評(píng)論