ontoggle = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The ontoggle event occurs when the user opens or closes the <details> element.

Summary

Bubbles No
Cancelable No
Supported HTML tags: <details>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<details ontoggle="myFunction()">
<summary>Copyright 2018-2020.</summary>
<p> - by java2s.com.</p>
</details>//  w  w  w . ja  v a  2 s  .c o  m

<script>
document.getElementById("myDetails").ontoggle = function() {myFunction()};

function myFunction() {
    console.log("The ontoggle event occured");
}
</script>

</body>
</html>

Related Tutorials