How to add a tooltip to a div using JavaScript? Last Updated : 04 Apr, 2023 Comments Improve Suggest changes 1 Likes Like Report Adding tooltip to div element displays a pop-up, whenever the mouse hovers over div. Syntax: html < div title = "" > </div> <script> $(document).ready(function() { $('[data-toggle="tooltip"]').tooltip(); }); </script> Tooltip Methods: .tooltip("show"): It is used to show the tooltip. .tooltip("hide"): It is used to hide the tooltip. .tooltip(options): It is used to activate the tooltip. .tooltip("destroy"): It is used to destroy the tooltip. .tooltip("toggle"): It is used to toggle the tooltip. Tooltip Events: show.bs.tooltip: Tooltip is about to show on the screen. shown.bs.tooltip: Tooltip is fully shown on the screen. hide.bs.tooltip: Tooltip is about to hide. hidden.bs.tooltip: Tooltip is fully hidden. Return Value: It returns a pop-up when user hovers over the div element. Example 1: html <!DOCTYPE html> <html lang="en"> <head> <title> Bootstrap Example </title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"> </script> </head> <body> <div class="container" title="ToolTip"> <h1 class="text-center "> GeeksforGeeks </h1> <h2 class="h4 text-center"> A Computer Science Portal for Geeks </h2> </div> <script> $(document).ready(function() { $('[data-toggle="tooltip"]').tooltip(); }); </script> </body> </html> Output: Before hovering over div: After hovering over div: Example 2: html <!DOCTYPE html> <html lang="en"> <head> <title> Bootstrap Example </title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"> </script> </head> <body> <div class="container" title="Wonders of the World"> <h1 class="text-center "> GeeksforGeeks </h1> <h2 class="h4"> List of 7 Wonders of the World </h2> <ul> <li>Great Wall of China</li> <li>Petra</li> <li>The Colosseum</li> <li>Chichen Itza</li> <li>Machu Picchu</li> <li>Taj Mahal</li> <li>Christ the Redeemer</li> </ul> </div> <script> $(document).ready(function() { $('[data-toggle="tooltip"]').tooltip(); }); </script> </body> </html> Output: Before hovering over div: After hovering over div: Browser Support: Browsers which support Tooltip: Opera Internet Explorer Safari Google Chrome Firefox Create Quiz Comment R riarawal99 Follow 1 Improve R riarawal99 Follow 1 Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like