Bootstrap 5 Tooltips Events Last Updated : 25 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Bootstrap 5 Tooltip is used to show additional information about an element when it is hovered by the user or comes into focus. There are five events that can be triggered by the tooltip in its lifecycle. These events are listed below.Bootstrap 5 Tooltips Events:hide.bs.tooltip: This tooltip event is triggered after the hide() method of the tooltip is called.hidden.bs.tooltip: This event is triggered after the tooltip is hidden from the screen.inserted.bs.tooltip: This event is fired after the "show.bs.tooltip" when the tooltip has been inserted in DOM.show.bs.tooltip: This tooltip event is triggered after the show() method of the tooltip is called.shown.bs.tooltip: This event is triggered after the tooltip is shown to the user.Syntax:tooltip.addEventListener('tooltip-event', () => { ....})Example 1: In this example, we used the show.bs.tooltip event of the tooltip to show a toast message when this event is fired. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap CSS --> <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" /> <!-- Bootstrap Javascript --> <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"> </script> </head> <body> <div class="container"> <div class="mt-5"> <h1 class="text-success">GeeksforGeeks</h1> <strong>Bootstrap5 Tooltip Events</strong> </div> <div class="toast-container p-2 top-0 start-50 translate-middle-x"> <div id="myToast" class="toast" data-bs-delay="1500"> <div class="toast-header"> <strong class="me-auto"> Tooltip Shown </strong> </div> <div class="toast-body"> <span id="msg"> show.bs.tooltip Event Fired </span> </div> </div> </div> <button id="tt" class="btn btn-primary mt-5 mb-3" data-bs-toggle="tooltip" data-bs-title="GeeksforGeeks"> Hover For Tooltip </button> </div> <script> // Enabling all the tooltips on the page. const tooltipElements = document.querySelectorAll('[data-bs-toggle="tooltip"]'); const tooltips = [...tooltipElements].map(el => new bootstrap.Tooltip(el)); const toast = new bootstrap.Toast(document.getElementById("myToast")); document.getElementById("tt").addEventListener('show.bs.tooltip', () => { toast.show(); }); </script> </body> </html> Output: Example 2: This example illustrates the use of the hidden.bs.tooltip event to show a toast message when the tooltip is completely hidden from the user. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap CSS --> <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" /> <!-- Bootstrap Javascript --> <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"> </script> </head> <body> <div class="container"> <div class="mt-5"> <h1 class="text-success">GeeksforGeeks</h1> <strong>Bootstrap5 Tooltip Events</strong> </div> <div class="toast-container p-2 top-0 start-50 translate-middle-x"> <div id="myToast" class="toast" role="alert" data-bs-delay="1500"> <div class="toast-header bg-danger text-white"> <strong class="me-auto"> Tooltip Hidden </strong> </div> <div class="toast-body bg-danger text-white"> <span id="msg"> hidden.bs.tooltip Event Triggered </span> </div> </div> </div> <button id="tt" class="btn btn-danger mt-5 mb-3" data-bs-toggle="tooltip" data-bs-title="GeeksforGeeks"> Hover For Tooltip </button> </div> <script> // Enabling all the tooltips on the page. const tooltipElements = document.querySelectorAll('[data-bs-toggle="tooltip"]'); const tooltips = [...tooltipElements].map(el => new bootstrap.Tooltip(el)); const toast = new bootstrap.Toast(document.getElementById("myToast")); document.getElementById("tt").addEventListener('hidden.bs.tooltip', () => { toast.show(); }); </script> </body> </html> Output: Reference: https://getbootstrap.com/docs/5.2/components/tooltips/#events Comment More infoAdvertise with us Next Article Bootstrap 5 Tooltips B badalmishra28 Follow Improve Article Tags : Technical Scripter Web Technologies Bootstrap Technical Scripter 2022 Bootstrap-5 +1 More Similar Reads Bootstrap 5 Tooltips A Tooltip is used to provide interactive textual hints to the user about the element when the mouse pointer moves over. The tooltip is quite useful for displaying the description of different elements on the webpage. To create a tooltip, we need to add the data-bs-toggle="tooltip" attribute to an el 3 min read Bootstrap 5 Enable Tooltips Everywhere Bootstrap 5 Tooltips can be enabled everywhere by first creating a list of all the tooltips and then enabling each of them. All the tooltips have an attribute named "data-bs-toggle" set to "tooltip". This attribute can be used to select all the tooltips using the document.querySelectorAll() method.B 2 min read Bootstrap 5 Tooltips Usage Bootstrap 5 Tooltips usage is used to create the markup and the text on the elements when required, and the tooltip created is placed after the element that was triggered. Using Javascript to launch Tooltips: var example = document.getElementById('...') var ... = new bootstrap.Tooltip(example, value 3 min read Bootstrap 5 Tooltips Usage Markup Bootstrap 5 Tooltip is one of the components which provide small, interactive, textual hints for elements. They are used to provide additional information about a specific element when the user hovers over it or focuses on it.Bootstrap 5 Tooltips Usage Markup: The markup required for the tooltips ar 2 min read Bootstrap 5 Tooltips Usage Disabled Elements Bootstrap 5 Tooltips are a JavaScript plugin that allows you to add small, interactive, text-based hints to elements on your web page. They are displayed when the user hovers over, clicks on, or focuses on the element. Tooltips can be used to provide additional information about an element, such as 2 min read Bootstrap 5 Tooltips Usage Options Bootstrap 5 Tooltip usage options can be passed through the data attributes or via JavaScript. To pass the options through data attributes we have to append the option name with the data-bs for example data-bs-animation="true".Some of the many options available are:animation: It is used to apply ani 4 min read Bootstrap 5 Tooltips using function with popperConfig Bootstrap 5 Tooltips Using function with popperConfig facilitates an interface that allows us to change the default Popper Configuration. Popper is a framework that helps us to create popups in websites. PopperConfig is actually an option in bootstrap.Tooltip class that can be initialized with an el 3 min read Bootstrap 5 Tooltips Usage Methods Bootstrap 5 Tooltips facilitates some pre-defined methods that we can use to trigger different types of functionalities in tooltips. The methods can be implemented using JavaScript and JQuery.Bootstrap 5 Tooltips Usage Methods: The Tooltips Methods with their function are given below:show(): The sho 4 min read Bootstrap 5 Tooltips show() Method Bootstrap 5 Tooltip is a UI element that shows some extra information when the user hovers over or focuses on a tooltip-enabled element. The Tooltip show() method is used to show an element's tooltip. The Tooltip having the zero title length will not be visible.Syntax:const tooltip = new bootstrap.T 2 min read Bootstrap 5 Tooltip hide() Method Bootstrap 5 Tooltip is used to show some extra information to the user when the user hovers over the element. The Tooltip hide() method is used to hide a visible tooltip.Syntax:bootstrap.Tooltip.getInstance("#tooltip-ID").hide();Parameters: This method accepts a single parameter that holds the toolt 2 min read Like