jQuery (non plugin) tooltip using jQuery ui position - How can this be improved? -
i need reviewing basic tooltip using jquery ui position. jquery tooltip gets title attribute off link , creates tooltip on hover of link. how can code improved , or made more efficient? wanted post here in hopes helps others. sure spent enough time on thought simple.
here code (would love people post alternate versions):
$(".tip a").hover( function() { var tiptext = $(this).attr("title"); $("<div class='tooltip' style='display:none;'>" + tiptext + " </div>").insertafter(this); $('.tooltip').position({ my: "left top", at: "right top", of: this, collision: "flip" }); //is there better way select tooltip? $(this).next().fadein(500); //should fade in way? }, function() { //should use better selector? $(this).next().fadeout('slow', function() { $(this).remove(); }); });
- should using ui position or other technique? i'm open better solutions.
- do know of better non plugin jquery tooltip?
- i refuse use plugin this.
- i heart stackoverflow
- jquery ui .position used above - http://jqueryui.com/demos/position/
ideas, thoughts, comments? all, hope helps others well!
use of jqueryui position() method dependent on if using jqueryui in page or not. waste load if need position.
not lot of effort calculate position using link offset offet() method , adustment width using width() method.
if loading jqueryui... position() convenient utility method , saves doing calcs yourself
edit: use of ui position "flip" option require considerably more effort code yourself
Comments
Post a Comment