YouTip LogoYouTip

Example Tooltip

## Default Functionality Hover over the links, or use the tab key to cycle focus through each element. jQuery UI Tooltip - Default Functionality $(function() { $( document ).tooltip(); }); label { display: inline-block; width: 5em; }

Tooltips can be bound to any element. When you hover the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

But since it's not a native tooltip, it can be styled. Themes created with ThemeRoller can style the tooltips accordingly.

Tooltips can also be used for form elements, to show some extra information in each field.

Hover the field to see the tooltip.

## Custom Styling Hover over the links, or use the tab key to cycle focus through each element. jQuery UI Tooltip - Custom Styling $(function() { $( document ).tooltip({ position: { my: "center bottom-20", at: "center top", using: function( position, feedback ) { $( this ).css( position ); $( "
" ) .addClass( "arrow" ) .addClass( feedback.vertical ) .addClass( feedback.horizontal ) .appendTo( this ); } } }); }); .ui-tooltip, .arrow:after { background: black; border: 2px solid white; } .ui-tooltip { padding: 10px 20px; color: white; border-radius: 20px; font: bold 14px "Helvetica Neue", Sans-Serif; text-transform: uppercase; box-shadow: 0 0 7px black; } .arrow { width: 70px; height: 16px; overflow: hidden; position: absolute; left: 50%; margin-left: -35px; bottom: -16px; } .arrow.top { top: -16px; bottom: auto; } .arrow.left { left: 20%; } .arrow:after { content: ""; position: absolute; left: 20px; top: -20px; width: 25px; height: 25px; box-shadow: 6px 5px 9px -9px black; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); tranform: rotate(45deg); } .arrow.top:after { bottom: -20px; top: auto; }

Tooltips can be bound to any element. When you hover the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

But since it's not a native tooltip, it can be styled. Themes created with ThemeRoller can style the tooltips accordingly.

Tooltips can also be used for form elements, to show some extra information in each field.

Hover the field to see the tooltip.

## Custom Animation This example demonstrates how to customize the animation using the show and hide options, as well as using the open event for custom animation. jQuery UI Tooltip - Custom Animation $(function() { $( "#show-option" ).tooltip({ show: { effect: "slideDown", delay: 250 } }); $( "#hide-option" ).tooltip({ hide: { effect: "explode", delay: 250 } }); $( "#open-event" ).tooltip({ show: null, position: { my: "left top", at: "left bottom" }, open: function( event, ui ) { ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" ); } }); });

There are many ways to customize the tooltip animation.

You can use the show and hide options.

You can also use the open event.

## Custom Content Demonstrates how to combine different event delegation tooltips into a single instance by customizing the items and content options. You may need to interact with map tooltips, which is a feature to be implemented in a future version. jQuery UI Tooltip - Custom Content .photo { width: 300px; text-align: center; } .photo .ui-widget-header { margin: 1em 0; } .map { width: 350px; height: 350px; } .ui-tooltip { max-width: 350px; } $(function() { $( document ).tooltip({ items: "img, , ", content: function() { var element = $( this ); if ( element.is( "" ) ) { var text = element.text(); return "" + text + ""; } if ( element.is( "" ) ) { return element.attr( "title" ); } if ( element.is( "img" ) ) { return element.attr( "alt" ); } } }); });

St. Stephen's Cathedral

Vienna, Austria

St. Stephen's Cathedral

Tower Bridge

London, England

Tower Bridge

All images are from Wikimedia Commons and are licensed under CC BY-SA 3.0 by their respective owners.

## Form Use the button below to show the help text, or just hover over or focus the input to show the help text for that input. A fixed width is defined in the CSS to make all help texts appear consistent when shown simultaneously. jQuery UI Tooltip - Form label { display: inline-block; width: 5em; } fieldset div { margin-bottom: 2em; } fieldset .help { display: inline-block; } .ui-tooltip { width: 210px; } $(function() { var tooltips = $( "" ).tooltip(); $( "
← Example EffectExample Tabs β†’