The ontoggle
attribute event is triggered
when opening or closing the <details> element.
The ontoggle
attribute is new in HTML5.
<details ontoggle="script">
<details>
details |
Yes | No | No | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<!-- w w w . ja v a2s.c o m-->
<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>