ref: master
public/javascripts/vendor/jquery-ui-1.10.4/development-bundle/docs/tooltip.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
<!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-close">close</a></div> <div><a href="#event-create">create</a></div> <div><a href="#event-open">open</a></div> </div></section><div class="longdesc" id="entry-longdesc"> <p>Tooltip replaces native tooltips, making them themeable 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 visibility. 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 id="theming">Theming</h3> <p>The tooltip widget uses the <a href="/theming/css-framework/">jQuery UI CSS framework</a> to style its look and feel. If tooltip specific styling is needed, the following CSS class names can be used:</p> </div> <ul> <li> <code>ui-tooltip</code>: The outer container for the tooltip. <ul> <li> <code>ui-tooltip-content</code>: The content of the tooltip.</li> </ul> </li> </ul> <h3>Dependencies</h3> <ul> <li><a href="/category/ui-core/">UI Core</a></li> <li><a href="/jQuery.widget/">Widget Factory</a></li> <li><a href="/position/">Position</a></li> <li> <a href="/category/effects-core/">Effects Core</a> (optional; for use with the <a href="#option-show"><code>show</code></a> and <a href="#option-hide"><code>hide</code></a> options)</li> </ul> </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>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 <code>content</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ content: <span class="string">"Awesome title!"</span> });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>content</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> content = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"content"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"content"</span>, <span class="string">"Awesome title!"</span> );</code></div></div></pre> </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 <code>disabled</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ disabled: <span class="literal">true</span> });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>disabled</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> disabled = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"disabled"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"disabled"</span>, <span class="literal">true</span> );</code></div></div></pre> </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>true</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 animation method, such as <code>"slideUp"</code>, or the name of a <a href="/category/effects/">jQuery UI effect</a>, 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>delay</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. If <code>delay</code> is omitted, then no delay is used.</li> </ul> <strong>Code examples:</strong><p>Initialize the tooltip with the <code>hide</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ hide: { effect: <span class="string">"explode"</span>, duration: <span class="number">1000</span> } });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>hide</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> hide = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"hide"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"hide"</span>, { effect: <span class="string">"explode"</span>, duration: <span class="number">1000</span> } );</code></div></div></pre> </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 <code>items</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ items: <span class="string">"img[alt]"</span> });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>items</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> items = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"items"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"items"</span>, <span class="string">"img[alt]"</span> );</code></div></div></pre> </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>Identifies the position of the tooltip in relation to the associated target element. The <code>of</code> option defaults to the target element, but you can specify another element to position against. You can refer to the <a href="/position/">jQuery UI Position</a> utility for more details about the various options.</p> </div> <strong>Code examples:</strong><p>Initialize the tooltip with the <code>position</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ position: { my: <span class="string">"left+15 center"</span>, at: <span class="string">"right center"</span> } });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>position</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> position = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"position"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"position"</span>, { my: <span class="string">"left+15 center"</span>, at: <span class="string">"right center"</span> } );</code></div></div></pre> </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>true</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 animation method, such as <code>"slideDown"</code>, or the name of a <a href="/category/effects/">jQuery UI effect</a>, 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>delay</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. If <code>delay</code> is omitted, then no delay is used.</li> </ul> <strong>Code examples:</strong><p>Initialize the tooltip with the <code>show</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ show: { effect: <span class="string">"blind"</span>, duration: <span class="number">800</span> } });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>show</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> show = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"show"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"show"</span>, { effect: <span class="string">"blind"</span>, duration: <span class="number">800</span> } );</code></div></div></pre> </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 <code>tooltipClass</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ tooltipClass: <span class="string">"custom-tooltip-styling"</span> });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>tooltipClass</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> tooltipClass = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"tooltipClass"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"tooltipClass"</span>, <span class="string">"custom-tooltip-styling"</span> );</code></div></div></pre> </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 <code>track</code> option specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({ track: <span class="literal">true</span> });</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Get or set the <code>track</code> option, after initialization:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="comment">// getter</span></code></div></div><div class="container"><div class="line"><code><span class="keyword">var</span> track = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"track"</span> );</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="comment">// setter</span></code></div></div><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"track"</span>, <span class="literal">true</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div></section><section id="methods"><header><h2>Methods</h2></header><div id="method-close"><div class="api-item first-item"> <h3>close()<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"close"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></div> <div id="method-destroy"><div class="api-item"> <h3>destroy()<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"destroy"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></div> <div id="method-disable"><div class="api-item"> <h3>disable()<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"disable"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></div> <div id="method-enable"><div class="api-item"> <h3>enable()<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"enable"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></div> <div id="method-open"><div class="api-item"> <h3>open()<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"open"</span> );</code></div></div></pre> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="keyword">var</span> isDisabled = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"disabled"</span> );</code></div></div></pre> </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 signature does not accept any arguments.</div></li></ul> <div> <strong>Code examples:</strong><p>Invoke the method:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="keyword">var</span> options = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div> <div class="api-item"> <h3>option( optionName, value )<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, <span class="string">"disabled"</span>, <span class="literal">true</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div> <div class="api-item"> <h3>option( options )<span class="returns">Returns: <a href="http://api.jquery.com/Types/#jQuery">jQuery</a> (<a href="http://learn.jquery.com/jquery-ui/widget-factory/widget-method-invocation/">plugin only</a>)</span> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip( <span class="string">"option"</span>, { disabled: <span class="literal">true</span> } );</code></div></div></pre> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="keyword">var</span> widget = $( <span class="string">".selector"</span> ).tooltip( <span class="string">"widget"</span> );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></div></section><section id="events"><header><h2>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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({</code></div></div><div class="container"><div class="line"><code> close: <span class="keyword">function</span>( event, ui ) {}</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Bind an event listener to the tooltipclose event:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).on( <span class="string">"tooltipclose"</span>, <span class="keyword">function</span>( event, ui ) {} );</code></div></div></pre> </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> <p><em>Note: The <code>ui</code> object is empty but included for consistency with other events.</em></p> <div> <strong>Code examples:</strong><p>Initialize the tooltip with the create callback specified:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({</code></div></div><div class="container"><div class="line"><code> create: <span class="keyword">function</span>( event, ui ) {}</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Bind an event listener to the tooltipcreate event:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).on( <span class="string">"tooltipcreate"</span>, <span class="keyword">function</span>( event, ui ) {} );</code></div></div></pre> </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 javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).tooltip({</code></div></div><div class="container"><div class="line"><code> open: <span class="keyword">function</span>( event, ui ) {}</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre> </td> </tr> </tbody> </table> </div> <p>Bind an event listener to the tooltipopen event:</p> <div class="syntaxhighlighter javascript nogutter"> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code>$( <span class="string">".selector"</span> ).on( <span class="string">"tooltipopen"</span>, <span class="keyword">function</span>( event, ui ) {} );</code></div></div></pre> </td> </tr> </tbody> </table> </div> </div> </div></section><section class="entry-examples" id="entry-examples"><header><h2>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 xml "> <table> <tbody> <tr> <td class="gutter"> <div class="line n1">1</div> <div class="line n2">2</div> <div class="line n3">3</div> <div class="line n4">4</div> <div class="line n5">5</div> <div class="line n6">6</div> <div class="line n7">7</div> <div class="line n8">8</div> <div class="line n9">9</div> <div class="line n10">10</div> <div class="line n11">11</div> <div class="line n12">12</div> <div class="line n13">13</div> <div class="line n14">14</div> <div class="line n15">15</div> <div class="line n16">16</div> <div class="line n17">17</div> <div class="line n18">18</div> <div class="line n19">19</div> <div class="line n20">20</div> <div class="line n21">21</div> </td> <td class="code"> <pre><div class="container"><div class="line"><code><span class="doctype"><!doctype html></span></code></div></div><div class="container"><div class="line"><code><span class="tag"><<span class="title">html</span> <span class="attribute">lang</span>=<span class="value">"en"</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"><<span class="title">head</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">meta</span> <span class="attribute">charset</span>=<span class="value">"utf-8"</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">title</span>></span>tooltip demo<span class="tag"></<span class="title">title</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">link</span> <span class="attribute">rel</span>=<span class="value">"stylesheet"</span> <span class="attribute">href</span>=<span class="value">"//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"//code.jquery.com/jquery-1.10.2.js"</span>></span><span class="javascript"></span><span class="tag"></<span class="title">script</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"//code.jquery.com/ui/1.10.4/jquery-ui.js"</span>></span><span class="javascript"></span><span class="tag"></<span class="title">script</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"></<span class="title">head</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"><<span class="title">body</span>></span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag"><<span class="title">p</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">a</span> <span class="attribute">href</span>=<span class="value">"#"</span> <span class="attribute">title</span>=<span class="value">"Anchor description"</span>></span>Anchor text<span class="tag"></<span class="title">a</span>></span></code></div></div><div class="container"><div class="line"><code> <span class="tag"><<span class="title">input</span> <span class="attribute">title</span>=<span class="value">"Input help"</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"></<span class="title">p</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"><<span class="title">script</span>></span><span class="javascript"></span></code></div></div><div class="container"><div class="line"><code> $( document ).tooltip();</code></div></div><div class="container"><div class="line"><code><span class="tag"></<span class="title">script</span>></span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag"></<span class="title">body</span>></span></code></div></div><div class="container"><div class="line"><code><span class="tag"></<span class="title">html</span>></span></code></div></div></pre> </td> </tr> </tbody> </table> </div> <h4>Demo:</h4> <div class="demo code-demo" data-height="80"></div> </div></section> </div></article> </body> </html> |