x
 
<!DOCTYPE html>
<html>
<body>
<p>本例使用 HTML DOM 将 "ontoggle" 事件分配给 details 元素。</p>
<p>打开 details。</p>
<details id="myDetails">
<summary>Copyright 1999-2014.</summary>
<p> - by W3School. All Rights Reserved.</p>
<p>All content and graphics on this web site are the property of W3School.</p>
</details>
<script>
document.getElementById("myDetails").ontoggle = function() {myFunction()};
function myFunction() {
  alert("The ontoggle event occured");
}
</script>
</body>
</html>