Open In App
Related Articles

jQuery jTippy Tooltip Plugin

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

In this article, we will learn how to implement the tooltip feature using the 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"
          href=
    <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>
 
 
    <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: 



Last Updated : 13 Jul, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads