In JavaScript:
object.ontoggle = function(){
myScript};
This example uses the HTML DOM to assign an "ontoggle" event to a details element.
<!DOCTYPE html> <html> <body> <p>Open the details.</p> <details id="myDetails"> <summary>Copyright 2020-2024.</summary> <p> - by java2s.com. All Rights Reserved.</p> <p>All content and graphics on this web site are the property of the java2s.com.</p> </details>//from w w w . j a va 2 s. co m <p id="demo"></p> <script> document.getElementById("myDetails").ontoggle = function() {myFunction()}; function myFunction() { document.getElementById("demo").innerHTML = "The ontoggle event occured"; } </script> </body> </html>
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <details> |