In this article, we will learn how to implement tooltip feature using jQuery jTippy Tooltip plugin.
Note: Please download the jQuery jTippy plugin in the working folder and include the required files in the head section of your HTML code.
<link href=”https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css”
rel=”stylesheet” type=”text/css”/><link href=”https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css”
rel=”stylesheet” type=”text/css”/><link href=”https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/darcula.min.css”
rel=”stylesheet” type=”text/css”/>
<link href=”jTippy.css” rel=”stylesheet” type=”text/css”/>
<script src=”https://code.jquery.com/jquery-3.5.1.min.js”></script>
<script src=”jTippy.min.js”></script>
Example 1: The following example demonstrates the basic functionality of jTippy Tooltip Plugin.
HTML
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>jQuery jTippy Tooltip Plugin</title> <meta name="description" content="jQuery tooltip plugin" /> <meta content="width=800, initial-scale=1" name="viewport" /> <link rel="stylesheet" href= integrity= "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"/> <link rel="stylesheet" css/font-awesome.min.css"/> <link rel="stylesheet" href= <link rel="stylesheet" href="jTippy.css" /> <script src= </script> <script src="jTippy.min.js"></script> <style> body, html { height: 60%; width: 60%; margin: 0px; font-family: Arial; } </style> </head> <body class="body text-center"> <h2 style="color: green;">GeeksForGeeks</h2> <b>jQuery jTippy tooltip plugin </b> <p></p> <a href="#" data-toggle="tooltip" title="This is tooltip"> This is a dummy link to show tooltip. </a> <script> $(function () { $('[data-toggle="tooltip"]').jTippy(); }); </script> </body> </html> |
Output:

Example 2: The following example demonstrates the use of various option settings and event triggering functions. Only a few are used below, the developer can explore and use them based on the application’s need. When the tooltip is shown to the users, on(‘jt-show’) event is triggered which displays the message in the HTML div with id “showDivID”. The message div is hidden once on(‘jt-hide’) event is triggered.
html
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>jQuery jTippy Tooltip Plugin</title> <meta name="description" content="jQuery tooltip plugin" /> <meta content="width=800, initial-scale=1" name="viewport" /> <link rel="stylesheet" href= integrity= "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"/> <link rel="stylesheet" href= <link rel="stylesheet" href= <link rel="stylesheet" href="jTippy.css" /> <script src= </script> <script src="jTippy.min.js"></script> <style> body, html { height: 100%; margin: 0px; font-family: Arial; } </style> </head> <body class="body text-center"> <h2 style="color: green;">GeeksForGeeks</h2> <b>jQuery jTippy tooltip plugin </b> <p></p> <a href="#" data-toggle="tooltip" title="A Tooltip is used to provide interactive textual hints to the user about the element when the mouse pointer moves over. Tooltip is quite useful for displaying the description of different elements in the webpage."> Hover or Focus to see tooltip </a> <div id="showDivID"></div> <!-- Option settings and events trigger--> <script> $(function () { $('[data-toggle="tooltip"]') .jTippy({ title: "Trying out jTippy tooltips", // The tooltip is displayed on mouse // over and focus event trigger: "hoverfocus", size: "medium", position: "auto", backdrop: false, theme: "black", singleton: true, close_on_outside_click: true, }) .on("jt-show", function (e, tooltip, hide) { // triggered on show tooltip ; $("#showDivID").html("Show tooltip event is triggered"); }) .on("jt-hide", function (e) { //triggered on tooltip hide $("#showDivID").hide(); }); }); </script> </body> </html> |
Output:

Output showing event triggers:

Recommended Posts:
- jQuery UI | Tooltip
- How to use complex HTML with twitter Bootstrap tooltip using jQuery ?
- How to Create Link Tooltip Using CSS3 and jQuery ?
- jQuery | Page Piling Plugin
- jQuery | Mask Plugin
- How to create a jQuery plugin with methods?
- jQuery | Multiscroll Plugin
- jQuery | DrawSVG Plugin
- jQuery | Product Tour Plugin
- jQuery | Alertify Plugin
- jQuery | Flickerplate Plugin
- jQuery | menu-aim plugin
- jQuery | Tagsort Plugin
- jQuery | RowGrid Plugin
- jQuery | Filer Plugin
- jQuery | Logos Distort Plugin
- jQuery | Flipping Gallery Plugin
- jQuery | Vertical Dot Navigation Plugin
- jQuery | table2excel Plugin
- jQuery | CLNDR Plugin
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

