我正在使用 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是否处于打开/活动状态?
发布评论