Easy Tutorial
❮ Api Icons Example Datepicker ❯

jQuery UI API - Tooltip Widget

Category

Widgets

Usage

Description: A customizable, themable tooltip widget that replaces the native tooltips.

Version Added: 1.9

The Tooltip widget replaces native tooltips, making them themable as well as allowing various customizations:

By default, a fading animation is used to show and hide the tooltip, which looks more dynamic than just toggling the visibility. This can be customized with the show and hide options.

The items and content options need to be kept in sync. If you change one, you need to change the other as well.

In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, as we need to listen for events to decide when to show and hide the tooltip. This leads to jQuery UI not guaranteeing any level of support for tooltips attached to disabled elements. This means if you need tooltips on disabled elements, you might need to use a mix of native tooltips and jQuery UI tooltips.

Theming

The Tooltip Widget uses the jQuery UI CSS Framework to define its appearance and style. To use the styles specific to tooltips, you can use the following CSS class names:

Dependencies

Additional Notes

Example

Using event delegation on all elements with a title attribute, create a tooltip on the document.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Tooltip Widget Demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>

<p>
  <a href="#" title="Anchor description">Anchor text</a>
  <input title="Input help">
</p>
<script>
  $(document).tooltip();
</script>

</body>
</html>

View Demo

❮ Api Icons Example Datepicker ❯