A tooltip is a tool that helps us provide more detailed information about specific areas of our website. The goal is to enhance the website’s interactivity to make it more user-friendly.
A tooltip provides additional information about specific tags or fields on a website. We achieve this by calling the jQuery tooltip()
method on the target element of our page. Let's take a look at the example below:
We apply a tooltip to the input field in the code above to provide extra information.
Lines 7–10: We link the jQuery CSS
and JS
libraries so that we can use the tooltip()
method.
Lines 12–14: We call the tooltip()
method on document
. This enables us to add a tooltip to the input infield.
Line 26: We add a tooltip
to the input field. This input field has an attribute title
that gives extra information for the tooltip
to display.
Note: The attribute
title
is displayed when the user hovers the cursor over the input field.