css menu close all open menus

时间:2015-05-08 09:52:48

标签: javascript jquery css

I have a menu called css menu.

When I click onto a link I want to close all popups that are open without the main menu.

I have found some examples, but they are not working for me.

IPasswordHasher
HashPassword

4 个答案:

答案 0 :(得分:0)

You can use the Vect3D.cpp function to check if the menu item has a submenu. Then by using the using namespace std; #include "Vect3D.h" Vect3D::Vect3D() : x(0), y(0), z(0) { } // empty body Vect3D::Vect3D(double xVal, double yVal, double zVal) : x(xVal), y(yVal), z(zVal) { } // empty body ostream& operator<<(ostream& os, const Vect3D& out) { os << "(" << out.x << ", " << out.y << ", " << out.z << ")"; return os; } function, you can toggle the submenu.

:has()

DEMO



Alternativ

This alternativ does the same as the code above. But it will also close the active menu when it's already open.

next()

DEMO

答案 1 :(得分:0)

This can help you! http://jsfiddle.net/Lxf2dLtL/

    function position(year, mon) //this function puts the images
    {
        $('#' + year + ' .' + mon).prepend('<img class="black_point" src="./images/circle.png"/>');    
    }
    function person () {
        var date;
        date=prompt('Birthday date','01/01/1935');
        var elem = date.split('/'); 
        var month= elem[1]; //we take the month
        var year=elem[2]; //we take the year
        var mon= num2mon(month);
        var rw=document.getElementById("table").rows.length;
        var cols = $("#table").find('tr')[0].cells.length;
        position(year,mon);
     draw();
    }


    function draw() { //this function draw the lines
        var table = document.getElementById("table");
        var images = table.getElementsByTagName("img");  
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        var x,y;

        canvas.width  = table.offsetWidth;
        canvas.height = table.offsetHeight;

          function connect(image) { //this function link the images
            var tabBcr = table.getBoundingClientRect();
            var imgBcr = image.getBoundingClientRect();
            ctx.beginPath();
            ctx.moveTo(x, y);

            x = imgBcr.left + (imgBcr.width / 2) - tabBcr.left;
            y = imgBcr.top + (imgBcr.height / 2) - tabBcr.top;

            ctx.lineTo(x, y);
            ctx.stroke();

            //ctx.fill(); //that's no work :S
            //ctx.closePath();

          }
        for(var i=0; i<images.length; i++){ 
          connect( images[i]);
        }
    }

答案 2 :(得分:0)

try this out:

-(NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
    NSView *myView = [outlineView makeViewWithIdentifier:@"FinderItemRowType" owner:self];

    NSArray *mySubviews = [myView subviews];

    for (NSView *view in mySubviews)
    {
        if ([view isKindOfClass:[NSTextField class]])
        {
            [(NSTextField *)view setDelegate:self];
        }

    }
    return myView;
}

答案 3 :(得分:0)

谢谢你们。 我找到了解决问题的方法。

$('#cssmenu a').on('click', function(e){
    e.preventDefault();
    $('#cssmenu li ul').css("display", "none");
    $(this).next().show();
    $('#menu-button').parent().removeClass('open');
});

要关闭主要的移动菜单按钮,我已在脚本

中添加了此按钮
    $('#menu-button').parent().removeClass('open');

并在css脚本中添加了

    #cssmenu li ul { display: block; }

页面加载时唯一剩下的就是再次阻止li ul。 这解决了这一切。

全部谢谢