Julius ShadowAspect Flimmel Julius ShadowAspect Flimmel - 1 year ago 203
Javascript Question

bootstrap dropdown open on pageload

Ive got this dropdown styled with bootstrap:

<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="posuvnik">15min <strong class="caret"></strong></a>

<ul class="dropdown-menu">
<li> <a href="#" onclick="setPosuvnik(1)">15min</a> </li>
<li> <a href="#" onclick="setPosuvnik(2)">1hod</a> </li>

and I want that dropdown menu to be rolled down on a page load, anyone know how to achieve that? thanks in advance :)

Answer Source

This little bit of jQuery script (I'm assuming you've loaded it becasue you're using Bootstrap) ought to do the trick. Once the DOM has loaded, it sends a click() to the dropdown toggle button.

$(document).ready(function () {

There is probably a way to do it in straight CSS, but without seeing more of your code it's hard to know.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download