jQuery簡單實現(xiàn)title提示效果示例
本文實例講述了jQuery簡單實現(xiàn)title提示效果的方法。分享給大家供大家參考,具體如下:
/*
調(diào)用示例:
$(document).ready(function(){
$('.quicktip').quberTip({
speed:200
});
});
<a href='' class='quicktip' title='Information about this link'>desktop publishing</a>
*/
jQuery.fn.quberTip = function (options) {
var defaults = {
speed: 500,
xOffset: 10,
yOffset: 10
};
var options = $.extend(defaults, options);
return this.each(function () {
var $this = jQuery(this);
if ($this.attr('title') != undefined) {
//Pass the title to a variable and then remove it from DOM
if ($this.attr('title') != '') {
var tipTitle = ($this.attr('title'));
} else {
var tipTitle = 'QuberTip';
}
//Remove title attribute
$this.removeAttr('title');
$(this).hover(function (e) {
// $(this).css('cursor', 'pointer');
$("body").append("<div id='tooltip'>" + tipTitle + "</div>");
$("#tooltip").css({ "position": "absolute",
"z-index": "9999",
"background": "#D3DDF5",
"background-image": "url(../../Quber_Image/Quber_Common/Quber_TB_TitltBG.png)",
"padding": "5px",
"opacity": "0.9",
"border": "1px solid #A3C0E8",
"-moz-border-radius": "3px",
"border-radius": "3px",
"-webkit-border-radius": "3px",
"font-weight": "normal",
"font-size": "12px",
"display": "none"
});
$("#tooltip")
.css("top", (e.pageY + defaults.xOffset) + "px")
.css("left", (e.pageX + defaults.yOffset) + "px")
.fadeIn(options.speed);
}, function () {
//Remove the tooltip from the DOM
$("#tooltip").remove();
});
$(this).mousemove(function (e) {
$("#tooltip")
.css("top", (e.pageY + defaults.xOffset) + "px")
.css("left", (e.pageX + defaults.yOffset) + "px");
});
}
});
};
更多關于jQuery相關內(nèi)容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結》、《jQuery form操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴展技巧總結》、《jQuery拖拽特效與技巧總結》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
JQuery 1.3.2以上版本中出現(xiàn)pareseerror錯誤的解決方法
最近正在做一個系統(tǒng),測試組那邊不停的報告bug:后臺、前臺各種列表報告js彈出窗錯誤,內(nèi)容僅僅是一句“pareseerror”!2011-01-01
動態(tài)設置form表單的action屬性的值的簡單方法
下面小編就為大家?guī)硪黄獎討B(tài)設置form表單的action屬性的值的簡單方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
基于jquery-resizable創(chuàng)建可調(diào)整大小的表(table)格
本文介紹如何基于jquery-resizable實現(xiàn)可調(diào)整表格(table)列寬的代碼,需要的朋友可以參考下2023-06-06

