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 style="padding-top: 60px;">

  <div class="mdui-container">
    <button id="tooltip" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">local_printshop</i></button>

    <div class="mdui-m-t-5">
      <button id="open" class="mdui-btn mdui-color-pink-accent mdui-m-a-1">open</button>
      <button id="close" class="mdui-btn mdui-color-pink-accent mdui-m-a-1">close</button>
      <button id="toggle" class="mdui-btn mdui-color-pink-accent mdui-m-a-1">toggle</button>
      <button id="getState" class="mdui-btn mdui-color-pink-accent mdui-m-a-1">getState</button>
    </div>
  </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.Tooltip('#tooltip', {
  content: 'Print'
});

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

$('#close').on('click', function () {
  inst.close();
});

$('#toggle').on('click', function () {
  inst.toggle();
});

$('#getState').on('click', function () {
  mdui.alert(inst.getState());
});

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

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

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

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