菜单下拉菜单不起作用 - Elementor Header Wordpress 上的菜单

Menu Dropdowns not working - Elementor Header Menu on Wordpress

header 是使用“Elementor - Header, Footer & Blocks”插件设计的。下拉菜单不起作用。已尝试激活、停用插件、清除缓存。

网站Link: https://www.party-monsters.com/

试试下面的代码。代码进入您的活动主题 functions.php 文件。

function add_custom_js(){
    ?>
    <script type="text/javascript">
        (function($){
            $(document).ready(function(){
                $('.hfe-has-submenu .hfe-menu-item').on('click',function(e){
                    e.preventDefault();
                    if( $(this).closest('li').find('.sub-menu').css('opacity') === '0' ){
                        $(this).closest('li').find('.sub-menu').css({"visibility": "visible", "opacity": "1"});
                    }else{
                        $(this).closest('li').find('.sub-menu').css({"visibility": "hidden", "opacity": "0"});
                    } 
                });
            });
        })(jQuery);
    </script>
    <?php
}
add_action( 'wp_footer', 'add_custom_js', 10, 1 );

已测试并有效。