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 of Bootstrap 4 Popovers</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script> <style> .bs-example{ margin: 150px 50px; } .bs-example button{ margin-right: 20px; } </style> <script> $(document).ready(function(){ // Showing and hiding popover with same speed $(".popover-tiny").popover({ delay: 500 // show tooltip after 500 milliseconds }); // Showing and hiding popover with different speed $(".popover-large").popover({ delay: {show: 0, hide: 2000} }); }); </script> </head> <body> <div class="bs-example"> <div id="myPopovers" class="mb-2"> <button type="button" class="btn btn-primary popover-tiny" data-toggle="popover" title="Popover Delay Demo" data-content="A small popover that show and hide after 500 milliseconds.">Popover Tiny</button> <button type="button" class="btn btn-secondary popover-large" data-toggle="popover" title="Popover Delay Demo" data-content="A large popover that displayed instantly on button click but hide after 2000 milliseconds after clicking the button once again.">Popover Large</button> </div> <p><strong>Note:</strong> Click on the buttons to show/hide the popover.</p> </div> </body> </html>