检测jQuery MMenu是否处于打开/活动状态? [英] Detect if jQuery MMenu is open/active?

查看:107
本文介绍了检测jQuery MMenu是否处于打开/活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery MMenu ,需要使用API​​来检测菜单是否打开

I'm using jQuery MMenu and need to use the API to detect whether or not the menu is open.

我已经查看了他们的事件页面,但是我不知道如何获得它状态.

I've looked over their Events page, but I cannot figure out how to get it's status.

有人请给我一个如何做这个事的例子吗?

Will someone please give me an example of how to do this?

推荐答案

从所述文档中,您可以使用:

From the docs stated, you can use:

1)opening事件,可在菜单打开时触发您的功能.

1) opening event to trigger your function when the menu is opening.

$("#nav").mmenu().trigger("open.mm").on("opening.mm", function() {
    alert( "The menu is opening" );
});

2)opened事件,当菜单完成打开时触发您的功能

2) opened event to trigger your function when the menu is finished opening

$("#nav").mmenu().trigger("open.mm").on("opened.mm", function() {
    alert( "The menu has just been opened." );
});


当您的menu处于活动状态时,它将在<nav id="left">中具有类mm-opened,您可以检查:


When your menu is active, it will has class mm-opened in <nav id="left">, you can check:

$('button').click(function() {
    if($('#left').hasClass('mm-opened')) {
        $("#nav").trigger("close.mm")
    }
});

这篇关于检测jQuery MMenu是否处于打开/活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆