HTML
CSS
JavaScript
HTML
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>菜单 - 通过 JavaScript 调用</title>
  <link rel="stylesheet" href="https://cdn.w3cbus.com/library/mdui/1.0.2/css/mdui.min.css"/>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">

  <div class="mdui-container mdui-p-t-5">
    <ul class="mdui-menu" id="menu">
      <li class="mdui-menu-item">
        <a href="javascript:;" class="mdui-ripple">Refresh</a>
      </li>
      <li class="mdui-menu-item">
        <a href="javascript:;" class="mdui-ripple">Settings</a>
      </li>
      <li class="mdui-menu-item">
        <a href="javascript:;" class="mdui-ripple">Send feedback</a>
      </li>
      <li class="mdui-menu-item">
        <a href="javascript:;" class="mdui-ripple">Help</a>
      </li>
      <li class="mdui-menu-item">
        <a href="javascript:;" class="mdui-ripple">Signout</a>
      </li>
    </ul>

    <button id="open" class="mdui-btn mdui-color-pink-accent">open</button>
  </div>

  <script src="https://cdn.w3cbus.com/library/mdui/1.0.2/js/mdui.min.js"></script>
</body>
</html>
CSS

  
JavaScript
var $ = mdui.$;
var inst = new mdui.Menu('#open', '#menu');

// method
$('#open').on('click', function () {
  inst.open();
});

// event
$('#menu').on('open.mdui.menu', function () {
  console.log('open');
});

$('#menu').on('opened.mdui.menu', function () {
  console.log('opened');
});

$('#menu').on('close.mdui.menu', function () {
  console.log('close');
});

$('#menu').on('closed.mdui.menu', function () {
  console.log('closed');
});