0

I am using bootstrap for a navigation and want to open the collapsed menu not just on a button click but already when hovering the button. I can't even find the javascript code for the already programmed clicked events.

That's the button to open the navigation:

<button class="navbar-toggle collapsed" data-target="#main-nav" data-toggle="collapse" aria-expanded="false">

That's the navigation to be opened:

<nav class="navbar navbar-fixed-top">
<div id="main-nav" class="navbar-collapse collapse" aria-expanded="false" style="height: 2px;">
<div class="container">

My problem:

I don't know how to deal with bootstrap ( couldn't find in the documentation ) to use hover on the button to open the navbar.

Code when the navigation is not collapsed:

<button class="navbar-toggle" data-target="#main-nav" data-toggle="collapse" aria-expanded="true">

<nav class="navbar navbar-fixed-top in">
<div id="main-nav" class="navbar-collapse collapse in" aria-expanded="true" style="">
<div class="container">
<ul class="nav navbar-nav">
<li class="col-xs-12 col-sm-2 with-sub">
<li class="col-xs-12 col-sm-2 with-sub">
Tommy
  • 851
  • 9
  • 24
dennis schütz
  • 383
  • 4
  • 21
  • Hey Dennis, I hardly understand your problem: you just want to open a menu when hovering a button? Can you give us a link to the website? – Tommy Mar 24 '16 at 10:14
  • yes i want to open the menu whem hovering the button, but also the click event. and the website isnt online yet – dennis schütz Mar 24 '16 at 10:25
  • But you actually know how to use jQuery hover event? Something like $('button.navbar-toggle').on('hover', function(){ // somethings happening here }) – Tommy Mar 24 '16 at 10:43
  • yep. but i think im getting in conflict with the other bootstrap events. – dennis schütz Mar 24 '16 at 10:48
  • I'd love to see an example of this and to better understand you... too bad it's not online yet. Maybe quickly recreate in jsfiddle? – Tommy Mar 24 '16 at 11:01
  • dont know if it would be legal to share the code :P since its a project for a company im workin for. maybe i can give u the acces to the website in private – dennis schütz Mar 24 '16 at 11:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/107214/discussion-between-tonsenson-and-dennis-schutz). – Tommy Mar 24 '16 at 11:41
  • Probably a duplicate of http://stackoverflow.com/questions/8878033/how-to-make-twitter-bootstrap-menu-dropdown-on-hover-rather-than-click? – Don't Panic Mar 24 '16 at 11:48
  • 1
    @dennisschütz Also please try to improve your writing the next time :) (or at least don't be lazy and add apostrophes) (already edited your post, I needs to be approved) – Tommy Mar 24 '16 at 12:38

1 Answers1

1

Possible and quick made up solution would be jQuery on combined with jQuery trigger function.

$('button.navbar-toggle.collapsed').on('mouseenter', function(){
  $(this).trigger('click');
})
Tommy
  • 851
  • 9
  • 24