I can't make bootstrap dropdown to work. Here is my html for nav:
<ul class='nav'> <li class='active'>Home</li> <li class='dropdown'> <a class="dropdown-toggle" data-toggle="dropdown" href='#'>Personal asset loans</a> <ul class="dropdown-menu" role="menu"> <li><a href="#">asds</a></li> <li class="divider"></li> </ul> </li> <li>Payday loans</li> <li>About</li> <li>Contact</li> </ul>
And here are the scripts:
<script type="text/javascript" src="js/bootstrap/bootstrap-dropdown.js"></script> <script> $(document).ready(function(){ $('.dropdown-toggle').dropdown() }); </script>
What am I doing wrong? Thanks for your answers!
Solution : The dropdown should be toggled via data attributes or using javascript. In the above program, we have forgotten to add a data attribute so the dropdown is not working. So add data-bs-toggle="dropdown" to toggle the dropdown.
Solution. The reason of this behaviour is the default setting for the mouse in Windows 10. By default the setting Scroll inactive windows when I hover over them in the Windows settings is turned on. If you switch this setting off, you can scroll again through large dropdown-menus.
To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.
Answer: Use the jQuery hover() method By default, to open or display the dropdown menu in Bootstrap you have to click on the trigger element. However, if you want to show the dropdown on mouseover instead of click you can do it with little customization using the CSS and jQuery.
I had the same problem. After a couple of hours of trouble shooting found that,
I had
<script type="text/javascript" src="Scripts/bootstrap.min.js"></script> <script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
instead of,
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
Hope this helps someone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With