以下代码在Google Chrome和Firefox中有效,但在IE8中无效。我不知道为什么,它是一个工具提示,使用jquery。这不是我的密码。在chrome或firefox上运行时,将鼠标悬停在元素上,工具提示将显示。在IE中,工具提示没有,似乎是悬停语句的问题。
我尝试了逐步调试,但jquery创建了十几个变量,这使得调试几乎不可能。
下面是代码
(function ($) {
$.fn.easyTooltip = function (options) {
// default configuration properties
var defaults = {
xOffset : 10,
yOffset : 45,
tooltipId : "tooltip",
clickRemove : false,
content : "",
useElement : "",
animation : true
};
var options = $.extend(defaults, options);
var content;
this.each(function () {
var title = $(this).attr("title");
$(this).hover(function (e) {
content = (options.content != "")
? options.content
: title;
content = (options.useElement != "") ? $("#"
+ options.useElement).html() : content;
$(this).attr("title", "");
if (content != "" && content != undefined) {
$("body").append("<div id='" + options.tooltipId
+ "'>" + content + "</div>");
$("#" + options.tooltipId).css("position",
"absolute").css("top",
(e.pageY - options.yOffset) + "px").css(
"left", (e.pageX + options.xOffset) + "px")
.css("display", "none");
if (options.animation == true) {
$("#" + options.tooltipId).animate({
marginTop : "12px",
opacity : "show"
}, 400);
} else {
$('#' + options.tooltipId).show();
}
}
}, function () {
$("#" + options.tooltipId).remove();
$(this).attr("title", title);
});
$(this).mousemove(function (e) {
$("#" + options.tooltipId).css("top",
(e.pageY - options.yOffset) + "px").css("left",
(e.pageX + options.xOffset) + "px")
});
if (options.clickRemove) {
$(this).mousedown(function (e) {
$("#" + options.tooltipId).remove();
$(this).attr("title", title);
});
}
});
};
})(jQuery);
你知道IE有什么问题吗?