O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Tooltips

$(document).tooltip({   items: "img, input",   position: {my:"left+15 top", at:"left bottom",              collision:"flipfit" },   content: function() {     var obj = $(this);     if (obj.is("input")) {       return obj.attr( "title" ); }     if (obj.is("img")) {       var img = $("<img></img>").addClass(         "mini").attr("src", obj.attr("src"));       var span = $("<span></span>").html(         obj.attr( "alt" ));       return $("<div></div>").append(img, span); }   }});

The tooltips widget allows you to easily add tooltips to form input, images, and just about any other page element. To implement the tooltips, apply .tooltip(options) to the document or other container. Inside the options ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required