Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  189] [ 2]  / answers: 1 / hits: 16125  / 11 Years ago, tue, february 4, 2014, 12:00:00

I can't seem to open this dropdown menu on page load. Can anyone help?
Documentation on Bootrap 3 is here: http://getbootstrap.com/javascript/#dropdowns



I tried this but it doesn't seem to work



$('#myDropdown').dropdown()


Ultimately, I need to be able to open a drop down that is inside a collapsible menu. For example, I want to open the first down down menu after the user clicks on the menu button. but I can't get it to work.



http://jsfiddle.net/G4k4F/3



Edit: When the navbar is shown, use a timer to wait 1 millisecond before calling .dropdown('toggle'). Like this.



function OpenDropDown() {
$('.dropdown-menu').dropdown('toggle');
};

$('.collapse.navbar-collapse').on('show.bs.collapse', function () {
window.setTimeout(OpenDropDown, 1);
});

More From » jquery

 Answers
35

try this :



$(function () {
$('.dropdown-menu').dropdown('toggle');
});

[#72721] Monday, February 3, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mickaylag

Total Points: 333
Total Questions: 108
Total Answers: 93

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
;