forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.tooltip.js
More file actions
38 lines (28 loc) · 804 Bytes
/
Copy pathjquery.tooltip.js
File metadata and controls
38 lines (28 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function($){
var showTip = function(e){
var element = $(this);
var val = element.attr("data-title");
var tip = $("<div />").addClass("tip")
tip.text(val);
var position = element.position();
if (element.attr("data-position") == "left") {
position.left -= element.width() + 10;
} else {
position.left += element.width() + 10;
}
position.top += 20;
tip.css({
position: "absolute",
left: position.left,
top: position.top,
zIndex: 1000
});
element.after(tip);
element.bind("mouseout", function(){
tip.fadeOut(300, function(){ tip.remove(); });
});
};
$.fn.tooltip = function(){
$(this).bind("mouseover", showTip);
};
})(jQuery);