<body>
  <div id="div1">
    <button id="button1">点击触发 frank 事件
    </button>
  </div>
</body>
button1.addEventListener('click', () => {
  const event = new CustomEvent("frank", {
    "detail": {
      name: 'frank',
      age: 18
    },
    "bubbles": true,
    "cancelable": false
  })
  button1.dispatchEvent(event)
})

button1.addEventListener('frank', (e) => {
  console.log('frank事件触发了')
  console.log(e.detail)
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.