- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Execute a script when the user opens or closes the element in HTML?
When a user opens or closes the <details> element, the ontoggle event fires. You can try to run the following code to implement ontoggle event attribute −
Example
<!DOCTYPE html> <html> <body> <h2>Details</h2> <p>You need to join office from Feb23<p> <details ontoggle="display()"> <summary>More Information</summary> <p>Timings: 9 to 5:30</p> <p>Office location: Hyderabad</p> </details> <script> function myFunction() { alert("Timings, office location, etc"); } </script> </body> </html>
- Related Articles
- Execute a script when the element gets user input in HTML?
- Execute a script when the user pastes some content in an element in HTML?
- Execute a script when the element is invalid in HTML?
- Execute a script when the element loses focus in HTML?
- Execute a script when the element gets focus in HTML?
- Execute a script when the media is paused either by the user or programmatically in HTML?
- Execute a script when a user releases a key in HTML?
- Execute a script when the element is finished loading in HTML?
- Execute a script when the element is being dragged in HTML?
- Execute a script when the element is being clicked in HTML?
- Execute a script when the cue changes in a element in HTML?
- Execute a script when the user writes something in a search field in HTML?
- Execute a script when a user is pressing a key in HTML?
- Execute a script when a user navigates to a page in HTML?
- Execute a script when the element is being double-clicked in HTML?

Advertisements