2
votes

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>
    </ul>
</li>

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

2

2 Answers

4
votes

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 () {
    $("#posuvnik").click();
});

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

5
votes

The dropdown is toggled with having the additional class 'open' added to the enclosing <li> element. So if you want to have it open on page loading:

<li class="dropdown open">

That will do the trick.