Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在wordpress菜单中使用jquery?_Jquery_Html_Wordpress_Menu_Menuitem - Fatal编程技术网

如何在wordpress菜单中使用jquery?

如何在wordpress菜单中使用jquery?,jquery,html,wordpress,menu,menuitem,Jquery,Html,Wordpress,Menu,Menuitem,我正在创建一个可湿性粉剂主题,我使用以下代码创建菜单: <?php $defaults = array( 'theme_location' => '', 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' =

我正在创建一个可湿性粉剂主题,我使用以下代码创建菜单:

<?php
$defaults = array(
'theme_location'  => '',
'menu'            => '',
'container'       => 'div',
'container_class' => '',
'container_id'    => '',
'menu_class'      => 'menu',
'menu_id'         => '',
'echo'            => true,
'fallback_cb'     => 'wp_page_menu',
'before'          => '',
'after'           => '',
'link_before'     => '',
'link_after'      => '',
'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth'           => 0,
'walker'          => '');  wp_nav_menu( $defaults );?>
(不完全是此代码)但问题是,我将一个项目悬停,所有
ul li ul li
项目都是影响和移动的!
如何指定?

您可以通过按类说明符缩小范围来指定悬停项的子菜单。在悬停事件回调中,您可以通过
this
获取悬停项DOM对象,因此将
子菜单
作为其同级菜单。然后,在子菜单上执行一些操作

$( ".menu-item a" ).hover(
    function()
    {
        $( this ).siblings( ".sub-menu" )
                 .animate( { "right": "300px" } );
    }
);

您可以通过类说明符缩小范围来指定悬停项的子菜单。在悬停事件回调中,您可以通过
this
获取悬停项DOM对象,因此将
子菜单
作为其同级菜单。然后,在子菜单上执行一些操作

$( ".menu-item a" ).hover(
    function()
    {
        $( this ).siblings( ".sub-menu" )
                 .animate( { "right": "300px" } );
    }
);

您可以通过类说明符缩小范围来指定悬停项的子菜单。在悬停事件回调中,您可以通过
this
获取悬停项DOM对象,因此将
子菜单
作为其同级菜单。然后,在子菜单上执行一些操作

$( ".menu-item a" ).hover(
    function()
    {
        $( this ).siblings( ".sub-menu" )
                 .animate( { "right": "300px" } );
    }
);

您可以通过类说明符缩小范围来指定悬停项的子菜单。在悬停事件回调中,您可以通过
this
获取悬停项DOM对象,因此将
子菜单
作为其同级菜单。然后,在子菜单上执行一些操作

$( ".menu-item a" ).hover(
    function()
    {
        $( this ).siblings( ".sub-menu" )
                 .animate( { "right": "300px" } );
    }
);

在WP中,我认为与菜单交互的最佳方式是使用它的本机类

例如,如果要在悬停特定项时显示其子菜单,只需使用以下命令:

$('.menu-item-has-children').on('mouseover',function(){
    $(this).children('.sub-menu').show();
}).on('mouseleave',function(){
    $(this).children('.sub-menu').hide();
});
这是工作表

编辑用户请求:

   $('.menu-item-has-children').on('click',function(){
        $(this).children('.sub-menu').show();
       return false;
    }).on('mouseleave',function(){
        $(this).children('.sub-menu').hide();
    });

这将使子菜单在单击时打开,但在您将鼠标放在WP中后将关闭它们。我认为与菜单交互的最佳方式是使用它的本机类

例如,如果要在悬停特定项时显示其子菜单,只需使用以下命令:

$('.menu-item-has-children').on('mouseover',function(){
    $(this).children('.sub-menu').show();
}).on('mouseleave',function(){
    $(this).children('.sub-menu').hide();
});
这是工作表

编辑用户请求:

   $('.menu-item-has-children').on('click',function(){
        $(this).children('.sub-menu').show();
       return false;
    }).on('mouseleave',function(){
        $(this).children('.sub-menu').hide();
    });

这将使子菜单在单击时打开,但在您将鼠标放在WP中后将关闭它们。我认为与菜单交互的最佳方式是使用它的本机类

例如,如果要在悬停特定项时显示其子菜单,只需使用以下命令:

$('.menu-item-has-children').on('mouseover',function(){
    $(this).children('.sub-menu').show();
}).on('mouseleave',function(){
    $(this).children('.sub-menu').hide();
});
这是工作表

编辑用户请求:

   $('.menu-item-has-children').on('click',function(){
        $(this).children('.sub-menu').show();
       return false;
    }).on('mouseleave',function(){
        $(this).children('.sub-menu').hide();
    });

这将使子菜单在单击时打开,但在您将鼠标放在WP中后将关闭它们。我认为与菜单交互的最佳方式是使用它的本机类

例如,如果要在悬停特定项时显示其子菜单,只需使用以下命令:

$('.menu-item-has-children').on('mouseover',function(){
    $(this).children('.sub-menu').show();
}).on('mouseleave',function(){
    $(this).children('.sub-menu').hide();
});
这是工作表

编辑用户请求:

   $('.menu-item-has-children').on('click',function(){
        $(this).children('.sub-menu').show();
       return false;
    }).on('mouseleave',function(){
        $(this).children('.sub-menu').hide();
    });

这将使子菜单在单击时打开,但在您将鼠标移开后将关闭它们

谢谢,您知道我如何应用此功能:我希望用户在单击母项时,它不会起作用!你知道我只是想当用户点击母亲的项目只是列表将被打开!我真的很感谢你的帮助,非常感谢:)谢谢你,你知道我该如何应用这个功能吗:我希望用户在点击母项时,它不会起作用!你知道我只是想当用户点击母亲的项目只是列表将被打开!我真的很感谢你的帮助,非常感谢:)谢谢你,你知道我该如何应用这个功能吗:我希望用户在点击母项时,它不会起作用!你知道我只是想当用户点击母亲的项目只是列表将被打开!我真的很感谢你的帮助,非常感谢:)谢谢你,你知道我该如何应用这个功能吗:我希望用户在点击母项时,它不会起作用!你知道我只是想当用户点击母亲的项目只是列表将被打开!我真的很感谢你的帮助,很好,非常感谢:)