前段時間,我使用JQuery 1.8.3創建了一個Balloon插件。插件停止使用JQuery 1.9.1
當我從JQuery 1.8.3更新到JQuery 1.9.1時,我的插件停止工作。
氣球不再顯示。我回到1.8.3,它的工作原理。
我試着瞭解什麼可能是錯的,但我找不到它。
請問有人能幫我嗎?這是我的代碼:
(function ($) {
$.fn.Balloon = function (options) {
var defaults = {
balloon: "",
class: "Balloon",
click: false,
id: "Balloon",
sensible: false,
x: -4,
y: -40
};
var options = $.extend({}, defaults, options);
var balloon;
$(this).each(function() {
var title = $(this).attr("title");
if (title == undefined) return;
$(this).hover(function (e) {
$(this).removeAttr("title")
balloon = "<div id='{id}' class='{class}'><span class='Text'>{content}</span><span class='Background'></span></div>"
if (options.balloon == "") {
balloon = balloon.replace("{class}", options.class).replace("{id}", options.id).replace("{content}", title);
} else {
balloon = balloon.replace("{class}", options.class).replace("{id}", options.id).replace("{content}", options.balloon).replace("{title}", title);
}
$("body").append(balloon);
$("#" + options.id).fadeIn("fast");
},
function() {
$("#" + options.id).remove();
$(this).attr("title", title);
});
$(this).mousedown(function (e) {
if (options.click) {
$("#" + options.id).remove();
$(this).attr("title", title);
}
}),
$(this).mousemove(function (e) {
var x = e.pageX + options.x;
var y = e.pageY + options.y;
if (options.sensible) {
var width = $("#" + options.id).width();
var height = $("#" + options.id).height();
var right = $(window).width() - (x + width);
var bottom = $(window).height() - (y + height);
if (right < 20) {
x = e.pageX - width - options.x;
}
if (bottom < 20) {
y = e.pageY - height - options.y;
}
}
$("#" + options.id).css({ top: y, left: x });
}); // Mouse Move
}); // Balloon
};
})(jQuery);