Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Activate Bootstrap Dropdown with Hover</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <style> .dropdown:hover .dropdown-menu{ display: block; } .dropdown-menu{ margin-top: 0; } </style> <script> $(document).ready(function(){ $(".dropdown").hover(function(){ var dropdownMenu = $(this).children(".dropdown-menu"); if(dropdownMenu.is(":visible")){ dropdownMenu.parent().toggleClass("open"); } }); }); </script> </head> <body> <nav class="navbar navbar-expand-sm navbar-dark bg-dark"> <a href="#" class="navbar-brand">Brand</a> <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarCollapse"> <div class="navbar-nav"> <a href="#" class="nav-item nav-link active">Home</a> <a href="#" class="nav-item nav-link">Profile</a> <div class="nav-item dropdown"> <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">Messages</a> <div class="dropdown-menu"> <a href="#" class="dropdown-item">Inbox</a> <a href="#" class="dropdown-item">Sent</a> <a href="#" class="dropdown-item">Drafts</a> </div> </div> </div> </div> </nav> </body> </html>