触发 ontoggle
属性事件当打开或关闭< details> 元件。
ontoggle
属性在HTML5中是新的。
<details ontoggle="script">
<details>
details |
Yes | No | No | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<details ontoggle="myFunction()">
<summary>Open the summary</summary>
<p>this is a test.</p>
</details>
<script>
function myFunction() {
console.log("The ontoggle event occured");
}
</script>
</body>
</html>