How can I make react-bootstrap's Dropdown open on mouse hover?

后端 未结 7 1810
-上瘾入骨i
-上瘾入骨i 2020-12-15 19:40

Ok the question is simple. I need to make the dropdown open when mouse hover rather than on click.

Currently my code is as follow.

    
7条回答
  •  无人及你
    2020-12-15 19:54

    You could replicate this https://codepen.io/bsngr/pen/frDqh which uses the following JS

    $('ul.nav li.dropdown').hover(function() {
      $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500);
    }, function() {
      $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500);
    });
    

    Or alternatively you could install a plugin like this https://github.com/CWSpear/bootstrap-hover-dropdown

    EDIT: Perfectly fine solutions to bootstrap but I noticed now you said its react and I havent used that before but I dont see why the js above wouldnt work even if it requires tweaking

提交回复
热议问题