实现Bootstrap菜单可点击及鼠标悬停显示下拉菜单

Author: 陌小雨Date: 2020-09-02View: 117

用bootstrap来作为wordpress主题前端开发是很不错的选择,陌小雨分享实战时用到的使Bootstrap菜单可点击及鼠标悬停显示下拉菜单的功能

$(document).ready(function(){
    //菜单可点击
    $(document).off('click.bs.dropdown.data-api');
    //鼠标滑过显示下拉菜单
     dropdownOpen();
});
function dropdownOpen() { 
    var $dropdownLi = $('li.dropdown'); 
    $dropdownLi.mouseover(function() {
        $(this).addClass('open');
    }).mouseout(function() {
        $(this).removeClass('open');
    });
}