Php 菜单下拉菜单不工作-Wordpress上的Elementor标题菜单
页眉是使用“Elementor-页眉、页脚和块”插件设计的。下拉菜单不起作用。尝试激活、停用插件、清除缓存 网站链接:Php 菜单下拉菜单不工作-Wordpress上的Elementor标题菜单,php,css,wordpress,custom-wordpress-pages,elementor,Php,Css,Wordpress,Custom Wordpress Pages,Elementor,页眉是使用“Elementor-页眉、页脚和块”插件设计的。下拉菜单不起作用。尝试激活、停用插件、清除缓存 网站链接: 试试下面的代码。代码放入活动的theme functions.php文件中 function add_custom_js(){ ?> <script type="text/javascript"> (function($){ $(document).ready(function()
试试下面的代码。代码放入活动的theme 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 );
函数add_custom_js(){
?>
(函数($){
$(文档).ready(函数(){
$('.hfe有子菜单.hfe菜单项')。在('click',函数(e){
e、 预防默认值();
if($(this).closest('li').find('.sub-menu').css('opacity')='0')){
$(this).closest('li').find('.sub-menu').css({“可见性”:“可见”,“不透明度”:“1”);
}否则{
$(this).closest('li').find('.sub-menu').css({“可见性”:“隐藏”,“不透明度”:“0”});
}
});
});
})(jQuery);
菜单不起作用,因为它被设置为单独的链接。您能告诉我,如何更改它吗?非常感谢@bhautik!@Omer Mustafa Welcome…我刚刚将javascript事件从单击更改为鼠标悬停,它工作得很轻松!这是可以的还是一个问题?不,没关系,您的解决方案工作得很轻松:)再次感谢@布提克