很簡單的程式碼,就不多廢話了。
代碼:
(function ($) {
$.fn.tips = function (text) {
var divtipsstyle = "position: absolute; left: 0; top: 0; background-color: #dceaf2; padding: 3px; border: solid 1px #6dbde4; visg;
$("body").append("
divtips.css("visibility", "visible");
var left = this.offset().left;
divtips.css("top", top);
divtips.css("left", left);
var top = e.clientY $(window).scrollTop() - divtips.height() - 12;
var left = e.clientX;
divtips.css("top", top);
divtips.css("left", left);
});
};
$(".div-tips").remove();
};
})($);
很實用吧,小夥伴們自由發揮下,結合到自己的專案中吧