2

What is the simplest way to change the Bootstrap menu from dropping down on click, rather than on hovering?

sample url: http://riverc.mgns.se

Can this be achieved via bootstrap, purely by CSS or a bit of JavaScript?

1

2 Answers 2

1

Add this line in your javascript code:

$('.dropdown-toggle').dropdownHover();
2
  • mmm... just tried on another site and get "Uncaught TypeError: Object [object Object] has no method 'dropdownHover' " I place it in my <head>
    – user991830
    Commented Mar 20, 2013 at 5:12
  • Add jQuery in your head first then in <script type="text/javasccript"> tag you will palce the above code :)
    – MarmiK
    Commented Mar 20, 2013 at 6:14
0

In twitter bootstrap dropdown, the dropdown is controlled by css so click like process cnt be done using css, so you have to use javascript or jquery for this...

Idea is that use two class for that toggle,

.off { display:none; }
.on { display:block; }

Develop your script with the help of this, http://api.jquery.com/toggleClass/

3
  • Ok... so I have a class of class="dropdown parent" on my li for the dropdown - how would I make this onclick via jQuery?
    – user991830
    Commented Mar 20, 2013 at 5:26
  • yes, but make sure the element you click and element you want to toggle class must have unique id...
    – SaurabhLP
    Commented Mar 20, 2013 at 5:29
  • ok... so I have it working where the dropdown stays down when clicked, but still drops down when hovered - jQuery('.dropdown-toggle').dropdown(); I need to take away the onhover - ideas?
    – user991830
    Commented Mar 20, 2013 at 5:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.