我写我自己的工具提示功能,像这样到中心提示:jQuery的尝试在悬停的元素
$(".tip_holder").hover(
function() {
var $containerWidth = $(this).width();
var $containerHeight = $(this).height();
var $tipTxt = $(this).text();
var $tipTitle = $(this).attr('title');
var $offset = $(this).offset();
$('#icis_dashboard').prepend('<div id="tooltip">' + $tipTxt + '</div>');
$('#tooltip').css({
'position': 'absolute'
});
var $tipWidth = $('#tooltip').width();
var $tipHeight = $('#tooltip').height();
$('#tooltip').css({
'top': $offset.top - ($tipHeight + 5),
'left': $offset.left,
'padding': '0 5px 5px'
});
},
function() {
$('#tooltip').remove();
}
);
但是我有困难定心了,我正在上空盘旋元素的提示。我需要这个来扩展到任何大小的元素。
我明白,有很多插件来实现这个功能,但我想写我自己的,所以tooltip div只会出现在代码中的相同位置,以便它可以由我的测试人员测试。这是他的要求让他的生活更轻松:(
您是否正在使用最新版本的jquery&jquery-ui? – Nalum 2010-07-27 09:27:10
是的。我并不认为jQuery UI支持工具提示。 – RyanP13 2010-07-27 09:28:51