简体   繁体   English

将Jquery垂直选项卡更改为菜单

[英]Changing Jquery vertical tabs to menu

Referring from http://mehdi.biz/blog/2010/02/05/vertical-tabs-for-jquery-lovers/ http://mehdi.biz/blog/2010/02/05/vertical-tabs-for-jquery-lovers/

i know it's very easy but i couldn't able to find a solution.. Just want to hide panel(content) when users move their mouse out from that icons.(Acting like a menu not like tabs don't want an active tab.) 我知道这很容易,但是我找不到解决方法。.当用户将鼠标从该图标移出时,只想隐藏面板(内容)。(像菜单一样,不像选项卡那样,不需要活动的选项卡)

How can i add that jquery code? 我如何添加该jQuery代码?

var $items3 = $('#vtab>ul>li');
$items3.mouseleave(function()
        {                           
        $('#vtab>div').hide();  
        }).mouseleave();

tried that code..it hides the tabs so i cant visit content of panel.. 尝试该代码..它隐藏了选项卡,所以我无法访问面板的内容。

Ex: http://arkansas.gov/ panel at right side 例如:右侧面板http://arkansas.gov/

You are triggering the mouseleave right after you have attached it. 您在附加鼠标后立即触发它。 Why? 为什么? Instead of the javascript on vertical-tabs and yours use this: Add display: none; 而不是您在vertical-tabs上使用javascript display: none; to #vtab > div in the css. 到CSS中的#vtab > div

    var $items = $('#vtab>ul>li');
    var $contents = $('#vtab>div');
    $items.on('mouseenter', function() {
        $items.removeClass('selected');
        $(this).addClass('selected');
        $contents.hide();
        var index = $items.index($(this));
        $contents.eq(index).show();
    });
    $('#vtab').on('mouseleave', function(){
        $items.removeClass('selected');
        $contents.hide();
    });

try it here . 在这里尝试。 This will only display the tab content and select the tab on mouseenter and hide the content and de-select the tab on mouseleave. 这只会显示选项卡内容,并在mouseenter上选择选项卡,然后隐藏内容并在mouseleave上取消选择该选项卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM