Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Setting Show/Hide Time Delay for Bootstrap Tooltips Using JavaScript</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script> <style> /* Some custom styles to beautify this example */ .bs-example{ margin: 100px 50px; } .bs-example a{ margin: 50px; } </style> <script> document.addEventListener("DOMContentLoaded", function(){ var tinyTrigger = document.getElementById("tinyTooltip"); var largeTrigger = document.getElementById("largeTooltip"); // Showing and hiding tooltip with same speed var tinyTooltip = new bootstrap.Tooltip(tinyTrigger, { delay: 100 // show, hide tooltip after 100 milliseconds }); // Showing and hiding tooltip with different speed var largeTooltip = new bootstrap.Tooltip(largeTrigger, { delay: {show: 0, hide: 2000} }); }); </script> </head> <body> <div class="bs-example"> <p> <a href="#" id="tinyTooltip" data-bs-toggle="tooltip" title="A small tooltip">Tooltip</a> <a href="#" id="largeTooltip" data-bs-toggle="tooltip" title="A large tooltip that displayed instantly on mouse hover but hide after 2000 milliseconds.">Large tooltip</a> </p> </div> </body> </html>