466 lines
44 KiB
HTML
466 lines
44 KiB
HTML
|
<!doctype html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<title>jQuery UI tooltip documentation</title>
|
||
|
|
||
|
<style>
|
||
|
body {
|
||
|
font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif"
|
||
|
}
|
||
|
.gutter {
|
||
|
display: none;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<script>{
|
||
|
"title":
|
||
|
"Tooltip Widget",
|
||
|
"excerpt":
|
||
|
"Customizable, themeable tooltips, replacing native tooltips.",
|
||
|
"termSlugs": {
|
||
|
"category": [
|
||
|
"widgets"
|
||
|
]
|
||
|
}
|
||
|
}</script><article id="tooltip1" class="entry widget"><h2 class="section-title">
|
||
|
<span>Tooltip Widget</span><span class="version-details">version added: 1.9</span>
|
||
|
</h2>
|
||
|
<div class="entry-wrapper">
|
||
|
<p class="desc"><strong>Description: </strong>Customizable, themeable tooltips, replacing native tooltips.</p>
|
||
|
<section id="quick-nav"><header><h2>QuickNav<a href="#entry-examples">Examples</a>
|
||
|
</h2></header><div class="quick-nav-section">
|
||
|
<h3>Options</h3>
|
||
|
<div><a href="#option-content">content</a></div>
|
||
|
<div><a href="#option-disabled">disabled</a></div>
|
||
|
<div><a href="#option-hide">hide</a></div>
|
||
|
<div><a href="#option-items">items</a></div>
|
||
|
<div><a href="#option-position">position</a></div>
|
||
|
<div><a href="#option-show">show</a></div>
|
||
|
<div><a href="#option-tooltipClass">tooltipClass</a></div>
|
||
|
<div><a href="#option-track">track</a></div>
|
||
|
</div>
|
||
|
<div class="quick-nav-section">
|
||
|
<h3>Methods</h3>
|
||
|
<div><a href="#method-close">close</a></div>
|
||
|
<div><a href="#method-destroy">destroy</a></div>
|
||
|
<div><a href="#method-disable">disable</a></div>
|
||
|
<div><a href="#method-enable">enable</a></div>
|
||
|
<div><a href="#method-open">open</a></div>
|
||
|
<div><a href="#method-option">option</a></div>
|
||
|
<div><a href="#method-widget">widget</a></div>
|
||
|
</div>
|
||
|
<div class="quick-nav-section">
|
||
|
<h3>Events</h3>
|
||
|
<div><a href="#event-create">create</a></div>
|
||
|
<div><a href="#event-open">open</a></div>
|
||
|
<div><a href="#event-close">close</a></div>
|
||
|
</div></section><div class="longdesc" id="entry-longdesc">
|
||
|
<p>Tooltip replaces native tooltips, making them themable as well as allowing various customizations:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>Display other content than just the title, like inline footnotes or extra content retrieved via Ajax.</li>
|
||
|
<li>Customize the positioning, e.g., to center the tooltip above elements.</li>
|
||
|
<li>Add extra styling to customize the appearance, for warning or error fields.</li>
|
||
|
</ul>
|
||
|
|
||
|
<p>A fade animation is used by default to show and hide the tooltip, making the appearance a bit more organic, compared to just toggling the visiblity. This can be customized with the <a href="#option-show"><code>show</code></a> and <a href="#option-hide"><code>hide</code></a> options.</p>
|
||
|
|
||
|
<p>The <a href="#option-items"><code>items</code></a> and <a href="#option-content"><code>content</code></a> options need to stay in-sync. If you change one of them, you need to change the other.</p>
|
||
|
|
||
|
<p>In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips.</p>
|
||
|
</div>
|
||
|
<h3>Additional Notes:</h3>
|
||
|
<div class="longdesc"><ul><li>
|
||
|
This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
|
||
|
</li></ul></div>
|
||
|
<section id="options"><header><h2 class="underline">Options</h2></header><div id="option-content" class="api-item first-item">
|
||
|
<h3>content<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types/#Function">Function</a>() or <a href="http://api.jquery.com/Types#String">String</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>function returning the title attribute</code>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>The content of the tooltip.</p>
|
||
|
|
||
|
<p><em>When changing this option, you likely need to also change the <a href="#option-items"><code>items</code></a> option.</em></p>
|
||
|
</div>
|
||
|
<strong>Multiple types supported:</strong><ul>
|
||
|
<li>
|
||
|
<strong>Function</strong>: A callback which can either return the content directly, or call the first argument, passing in the content, e.g., for Ajax content.</li>
|
||
|
<li>
|
||
|
<strong>String</strong>: A string of HTML to use for the tooltip content.</li>
|
||
|
</ul>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the content option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ content: </code><code class="string">"Awesome title!"</code> <code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the content option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">content = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"content"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"content"</code><code class="plain">, </code><code class="string">"Awesome title!"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-disabled" class="api-item">
|
||
|
<h3>disabled<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Boolean">Boolean</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>false</code>
|
||
|
</div>
|
||
|
<div>Disables the tooltip if set to <code>true</code>.</div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the disabled option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ disabled: </code><code class="keyword">true</code> <code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the disabled option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">disabled = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"disabled"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"disabled"</code><code class="plain">, </code><code class="keyword">true</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-hide" class="api-item">
|
||
|
<h3>hide<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Boolean">Boolean</a> or <a href="http://api.jquery.com/Types#Number">Number</a> or <a href="http://api.jquery.com/Types#String">String</a> or <a href="http://api.jquery.com/Types#Object">Object</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>null</code>
|
||
|
</div>
|
||
|
<div>If and how to animate the hiding of the tooltip.</div>
|
||
|
<strong>Multiple types supported:</strong><ul>
|
||
|
<li>
|
||
|
<strong>Boolean</strong>:
|
||
|
When set to <code>false</code>, no animation will be used and the tooltip will be hidden immediately.
|
||
|
When set to <code>true</code>, the tooltip will fade out with the default duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>Number</strong>:
|
||
|
The tooltip will fade out with the specified duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>String</strong>:
|
||
|
The tooltip will be hidden using the specified effect.
|
||
|
The value can either be the name of a built-in jQuery animateion method, such as <code>"slideUp"</code>, or the name of a jQuery UI effect, such as <code>"fold"</code>.
|
||
|
In either case the effect will be used with the default duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>Object</strong>: If the value is an object, then <code>effect</code>, <code>duration</code>, and <code>easing</code> properties may be provided. If the <code>effect</code> property contains the name of a jQuery method, then that method will be used; otherwise it is assumed to be the name of a jQuery UI effect. When using a jQuery UI effect that supports additional settings, you may include those settings in the object and they will be passed to the effect. If <code>duration</code> or <code>easing</code> is omitted, then the default values will be used. If <code>effect</code> is omitted, then <code>"fadeOut"</code> will be used.</li>
|
||
|
</ul>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the hide option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ hide: { effect: </code><code class="string">"explode"</code><code class="plain">, duration: 1000 } });</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the hide option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">hide = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"hide"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"hide"</code><code class="plain">, { effect: </code><code class="string">"explode"</code><code class="plain">, duration: 1000 } );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-items" class="api-item">
|
||
|
<h3>items<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Selector">Selector</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>[title]</code>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>A selector indicating which items should show tooltips. Customize if you're using something other then the title attribute for the tooltip content, or if you need a different selector for event delegation.</p>
|
||
|
|
||
|
<p><em>When changing this option, you likely need to also change the <a href="#option-content"><code>content</code></a> option.</em></p>
|
||
|
</div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the items option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ items: </code><code class="string">"img[alt]"</code> <code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the items option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">items = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"items"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"items"</code><code class="plain">, </code><code class="string">"img[alt]"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-position" class="api-item">
|
||
|
<h3>position<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Object">Object</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>{ my: "left top+15", at: "left bottom", collision: "flipfit" }</code>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>Configuration for the Position utility. The <code>of</code> property defaults to the target element, but can also be overriden.</p>
|
||
|
|
||
|
<p><em>Note: In 1.9.0, the default value was <code>{ my: "left+15 center", at: "right center", collision: "flipfit" }</code>, but this was changed to more closely match native tooltip positioning.</em></p>
|
||
|
</div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the position option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ position: { my: </code><code class="string">"left+15 center"</code><code class="plain">, at: </code><code class="string">"right center"</code> <code class="plain">} });</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the position option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">position = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"position"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"position"</code><code class="plain">, { my: </code><code class="string">"left+15 center"</code><code class="plain">, at: </code><code class="string">"right center"</code> <code class="plain">} );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-show" class="api-item">
|
||
|
<h3>show<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Boolean">Boolean</a> or <a href="http://api.jquery.com/Types#Number">Number</a> or <a href="http://api.jquery.com/Types#String">String</a> or <a href="http://api.jquery.com/Types#Object">Object</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>null</code>
|
||
|
</div>
|
||
|
<div>If and how to animate the showing of the tooltip.</div>
|
||
|
<strong>Multiple types supported:</strong><ul>
|
||
|
<li>
|
||
|
<strong>Boolean</strong>:
|
||
|
When set to <code>false</code>, no animation will be used and the tooltip will be shown immediately.
|
||
|
When set to <code>true</code>, the tooltip will fade in with the default duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>Number</strong>:
|
||
|
The tooltip will fade in with the specified duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>String</strong>:
|
||
|
The tooltip will be shown using the specified effect.
|
||
|
The value can either be the name of a built-in jQuery animateion method, such as <code>"slideDown"</code>, or the name of a jQuery UI effect, such as <code>"fold"</code>.
|
||
|
In either case the effect will be used with the default duration and the default easing.
|
||
|
</li>
|
||
|
<li>
|
||
|
<strong>Object</strong>: If the value is an object, then <code>effect</code>, <code>duration</code>, and <code>easing</code> properties may be provided. If the <code>effect</code> property contains the name of a jQuery method, then that method will be used; otherwise it is assumed to be the name of a jQuery UI effect. When using a jQuery UI effect that supports additional settings, you may include those settings in the object and they will be passed to the effect. If <code>duration</code> or <code>easing</code> is omitted, then the default values will be used. If <code>effect</code> is omitted, then <code>"fadeIn"</code> will be used.</li>
|
||
|
</ul>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the show option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ show: { effect: </code><code class="string">"blind"</code><code class="plain">, duration: 800 } });</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the show option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">show = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"show"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"show"</code><code class="plain">, { effect: </code><code class="string">"blind"</code><code class="plain">, duration: 800 } );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-tooltipClass" class="api-item">
|
||
|
<h3>tooltipClass<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#String">String</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>null</code>
|
||
|
</div>
|
||
|
<div>
|
||
|
A class to add to the widget, can be used to display various tooltip types, like warnings or errors.
|
||
|
<p>This may get replaced by the <a href="http://bugs.jqueryui.com/ticket/7053">classes option</a>.</p>
|
||
|
</div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the tooltipClass option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ tooltipClass: </code><code class="string">"custom-tooltip-styling"</code> <code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the tooltipClass option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">tooltipClass = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"tooltipClass"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"tooltipClass"</code><code class="plain">, </code><code class="string">"custom-tooltip-styling"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
<div id="option-track" class="api-item">
|
||
|
<h3>track<span class="option-type"><strong>Type: </strong><a href="http://api.jquery.com/Types#Boolean">Boolean</a></span>
|
||
|
</h3>
|
||
|
<div class="default">
|
||
|
<strong>Default: </strong><code>false</code>
|
||
|
</div>
|
||
|
<div>
|
||
|
Whether the tooltip should track (follow) the mouse.
|
||
|
</div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the track option specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({ track: </code><code class="keyword">true</code> <code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Get or set the track option, after initialization:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="comments">// getter</code></div><div class="line number2 index1 alt1"><code class="keyword">var</code> <code class="plain">track = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"track"</code> <code class="plain">);</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="comments">// setter</code></div><div class="line number5 index4 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"track"</code><code class="plain">, </code><code class="keyword">true</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div></section><section id="methods"><header><h2 class="underline">Methods</h2></header><div id="method-close"><div class="api-item first-item">
|
||
|
<h3>close()</h3>
|
||
|
<div>
|
||
|
Closes a tooltip. This is only intended to be called for non-delegated tooltips.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the close method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"close"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div>
|
||
|
<div id="method-destroy"><div class="api-item">
|
||
|
<h3>destroy()</h3>
|
||
|
<div>
|
||
|
Removes the tooltip functionality completely. This will return the element back to its pre-init state.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the destroy method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"destroy"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div>
|
||
|
<div id="method-disable"><div class="api-item">
|
||
|
<h3>disable()</h3>
|
||
|
<div>
|
||
|
Disables the tooltip.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the disable method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"disable"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div>
|
||
|
<div id="method-enable"><div class="api-item">
|
||
|
<h3>enable()</h3>
|
||
|
<div>
|
||
|
Enables the tooltip.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the enable method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"enable"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div>
|
||
|
<div id="method-open"><div class="api-item">
|
||
|
<h3>open()</h3>
|
||
|
<div>
|
||
|
Programmatically open a tooltip. This is only intended to be called for non-delegated tooltips.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the open method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"open"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div>
|
||
|
<div id="method-option">
|
||
|
<div class="api-item">
|
||
|
<h3>option( optionName )<span class="returns">Returns: <a href="http://api.jquery.com/Types#Object">Object</a></span>
|
||
|
</h3>
|
||
|
<div>Gets the value currently associated with the specified <code>optionName</code>.</div>
|
||
|
<ul><li>
|
||
|
<div><strong>optionName</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#String">String</a>
|
||
|
</div>
|
||
|
<div>The name of the option to get.</div>
|
||
|
</li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="keyword">var</code> <code class="plain">isDisabled = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"disabled"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="api-item">
|
||
|
<h3>option()<span class="returns">Returns: <a href="http://api.jquery.com/Types#PlainObject">PlainObject</a></span>
|
||
|
</h3>
|
||
|
<div>Gets an object containing key/value pairs representing the current tooltip options hash.</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="keyword">var</code> <code class="plain">options = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="api-item">
|
||
|
<h3>option( optionName, value )</h3>
|
||
|
<div>Sets the value of the tooltip option associated with the specified <code>optionName</code>.</div>
|
||
|
<ul>
|
||
|
<li>
|
||
|
<div><strong>optionName</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#String">String</a>
|
||
|
</div>
|
||
|
<div>The name of the option to set.</div>
|
||
|
</li>
|
||
|
<li>
|
||
|
<div><strong>value</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Object">Object</a>
|
||
|
</div>
|
||
|
<div>A value to set for the option.</div>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, </code><code class="string">"disabled"</code><code class="plain">, </code><code class="keyword">true</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="api-item">
|
||
|
<h3>option( options )</h3>
|
||
|
<div>Sets one or more options for the tooltip.</div>
|
||
|
<ul><li>
|
||
|
<div><strong>options</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Object">Object</a>
|
||
|
</div>
|
||
|
<div>A map of option-value pairs to set.</div>
|
||
|
</li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"option"</code><code class="plain">, { disabled: </code><code class="keyword">true</code> <code class="plain">} );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="method-widget"><div class="api-item">
|
||
|
<h3>widget()<span class="returns">Returns: <a href="http://api.jquery.com/Types#jQuery">jQuery</a></span>
|
||
|
</h3>
|
||
|
<div>
|
||
|
Returns a <code>jQuery</code> object containing the original element.
|
||
|
</div>
|
||
|
<ul><li><div class="null-signature">This method does not accept any arguments.</div></li></ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Invoke the widget method:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="keyword">var</code> <code class="plain">widget = $( </code><code class="string">".selector"</code> <code class="plain">).tooltip( </code><code class="string">"widget"</code> <code class="plain">);</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></div></section><section id="events"><header><h2 class="underline">Events</h2></header><div id="event-close" class="api-item first-item">
|
||
|
<h3>close( event, ui )<span class="returns">Type: <code>tooltipclose</code></span>
|
||
|
</h3>
|
||
|
<div>
|
||
|
Triggered when a tooltip is closed, triggered on <code>focusout</code> or <code>mouseleave</code>.
|
||
|
</div>
|
||
|
<ul>
|
||
|
<li>
|
||
|
<div><strong>event</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Event">Event</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
</li>
|
||
|
<li>
|
||
|
<div><strong>ui</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Object">Object</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
<ul><li>
|
||
|
<div><strong>tooltip</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#jQuery">jQuery</a>
|
||
|
</div>
|
||
|
<div>The generated tooltip element.</div>
|
||
|
</li></ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the close callback specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({</code></div><div class="line number2 index1 alt1"><code class="undefined spaces"> </code><code class="plain">close: </code><code class="keyword">function</code><code class="plain">( event, ui ) {}</code></div><div class="line number3 index2 alt2"><code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Bind an event listener to the tooltipclose event:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).on( </code><code class="string">"tooltipclose"</code><code class="plain">, </code><code class="keyword">function</code><code class="plain">( event, ui ) {} );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="event-create" class="api-item">
|
||
|
<h3>create( event, ui )<span class="returns">Type: <code>tooltipcreate</code></span>
|
||
|
</h3>
|
||
|
<div>
|
||
|
Triggered when the tooltip is created.
|
||
|
</div>
|
||
|
<ul>
|
||
|
<li>
|
||
|
<div><strong>event</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Event">Event</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
</li>
|
||
|
<li>
|
||
|
<div><strong>ui</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Object">Object</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the create callback specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({</code></div><div class="line number2 index1 alt1"><code class="undefined spaces"> </code><code class="plain">create: </code><code class="keyword">function</code><code class="plain">( event, ui ) {}</code></div><div class="line number3 index2 alt2"><code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Bind an event listener to the tooltipcreate event:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).on( </code><code class="string">"tooltipcreate"</code><code class="plain">, </code><code class="keyword">function</code><code class="plain">( event, ui ) {} );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="event-open" class="api-item">
|
||
|
<h3>open( event, ui )<span class="returns">Type: <code>tooltipopen</code></span>
|
||
|
</h3>
|
||
|
<div>
|
||
|
Triggered when a tooltip is shown, triggered on <code>focusin</code> or <code>mouseover</code>.
|
||
|
</div>
|
||
|
<ul>
|
||
|
<li>
|
||
|
<div><strong>event</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Event">Event</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
</li>
|
||
|
<li>
|
||
|
<div><strong>ui</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#Object">Object</a>
|
||
|
</div>
|
||
|
<div></div>
|
||
|
<ul><li>
|
||
|
<div><strong>tooltip</strong></div>
|
||
|
<div>Type: <a href="http://api.jquery.com/Types#jQuery">jQuery</a>
|
||
|
</div>
|
||
|
<div>The generated tooltip element.</div>
|
||
|
</li></ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<strong>Code examples:</strong><p>Initialize the tooltip with the open callback specified:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).tooltip({</code></div><div class="line number2 index1 alt1"><code class="undefined spaces"> </code><code class="plain">open: </code><code class="keyword">function</code><code class="plain">( event, ui ) {}</code></div><div class="line number3 index2 alt2"><code class="plain">});</code></div></div></td></tr></tbody></table></div>
|
||
|
<p>Bind an event listener to the tooltipopen event:</p>
|
||
|
<div class="syntaxhighlighter nogutter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain">$( </code><code class="string">".selector"</code> <code class="plain">).on( </code><code class="string">"tooltipopen"</code><code class="plain">, </code><code class="keyword">function</code><code class="plain">( event, ui ) {} );</code></div></div></td></tr></tbody></table></div>
|
||
|
</div>
|
||
|
</div></section><section class="entry-examples" id="entry-examples"><header><h2 class="underline">Example:</h2></header><div class="entry-example" id="example-0">
|
||
|
<h4><span class="desc">Create a tooltip on the document, using event delegation for all elements with a title attribute.</span></h4>
|
||
|
<div class="syntaxhighlighter "><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="plain"><!doctype html></code></div><div class="line number2 index1 alt1"><code class="plain"><</code><code class="keyword">html</code> <code class="color1">lang</code><code class="plain">=</code><code class="string">"en"</code><code class="plain">></code></div><div class="line number3 index2 alt2"><code class="plain"><</code><code class="keyword">head</code><code class="plain">></code></div><div class="line number4 index3 alt1"><code class="undefined spaces"> </code><code class="plain"><</code><code class="keyword">meta</code> <code class="color1">charset</code><code class="plain">=</code><code class="string">"utf-8"</code><code class="plain">></code></div><div class="line number5 index4 alt2"><code class="undefined spaces"> </code><code class="plain"><</code><code class="keyword">title</code><code class="plain">>tooltip demo</</code><code class="keyword">title</code><code class="plain">></code></div><div class="line number6 index5 alt1"><code class="undefined spaces"> </code><code class="plain"><</code><code class="keyword">link</code> <code class="color1">rel</code><code class="plain">=</code><code class="string">"stylesheet"</code> <code class="color1">href</code><code class="plain">=</code><code class="string">"<a href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css</a>"</code><code class="plain">></code></div><div class="line number7 index6 alt2"><code class="undefined spaces"> </code><code class="plain"><</code><code class="keyword">script</code> <code class="color1">src</code><code class="plain">=</code><code class="string">"<a href="http://code.jquery.com/jquery-1.8.3.js">http://code.jquery.com/jquery-1.8.3.js</a>"</code><code class="plain">></</code><code class="keyword">script</code><code class="plain">></code></div><div class="line number8 index7 alt1"><code class="undefined spaces"> </code><code class="plain"><</code><code class="keyword">script</code> <code class="color1">src</code><code class="plain">=</code><code class="string">"<a href="http://code.jquery.com/ui/1.9.2/jquery-ui.js">http://code.jquery.com/ui/1.9.2/jquery-ui.js</a>"</code><code class="plain">></</code><code class="keyword">script</code><code class="plain">></code></div><div class="line number9 index8 alt2"><code class="plain"></</code><code class="keyword">head</code><code class="plain">></code></div><div class="line number10 index9 alt1"><code class="plain"><</code><code class="keyword">body</code><code class="plain">></code></div><div class="line number11 index10 alt2"> </div><div class="line number12 index11 alt1"><code class="plain"><</code><code class="keyword">p</code><code class="plain">></code></d
|
||
|
<h4>Demo:</h4>
|
||
|
<div class="demo code-demo" data-height="80"></div>
|
||
|
</div></section>
|
||
|
</div></article>
|
||
|
|
||
|
</body>
|
||
|
</html>
|