Hello,
I have found on the internet a really cool tooltip (not from dynamicdrive)
Where I found it they dind't give any explanation about how to use it for newbies like me..
First code:
Second:Code:/** * * simpleTooltip jQuery plugin, by Marius ILIE * visit *** for details * **/ (function($){ $.fn.simpletooltip = function(){ return this.each(function() { var text = $(this).attr("title"); $(this).attr("title", ""); if(text != undefined) { $(this).hover(function(e){ var tipX = e.pageX + 12; var tipY = e.pageY + 12; $(this).attr("title", ""); $("body").append("<div id='simpleTooltip' style='position: absolute; z-index: 100; display: none;'>" + text + "</div>"); if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true) else var tipWidth = $("#simpleTooltip").width() $("#simpleTooltip").width(tipWidth); $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium"); }, function(){ $("#simpleTooltip").remove(); $(this).attr("title", text); }); $(this).mousemove(function(e){ var tipX = e.pageX + 12; var tipY = e.pageY + 12; var tipWidth = $("#simpleTooltip").outerWidth(true); var tipHeight = $("#simpleTooltip").outerHeight(true); if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth; if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight; $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium"); }); } }); }})(jQuery);
Read me:Code:$(document).ready(function(){ $(".with-tooltip").simpletooltip(); });
I really don't understandCode:Usage instructions - if the element has a TITLE attribute: $("#some-element").simpletooltip();how does it apply on a text, image etc.?



how does it apply on a text, image etc.?
Reply With Quote



Bookmarks