Toggle HTML Display With JavaScript
Here's a quick JavaScript trick to control display settings. All we do is set the display of an element to none, and then use a JavaScript function to toggle the display when a user clicks something else.
Steps
- Wrap the content you want to toggle display with in a container. Template:CodeBox
- Insert JavaScript code to change the display. Template:CodeBox
- Use an event handler to trigger the function. Template:CodeBox
Tips
- See examples and source code at Circlecube
Related Articles
- Make Blinking Text Without the Text Tag or JavaScript
- Create JavaScript Conditional Operators
- Use the JavaScript Confirm Function
- View Source Code
- Make a Collapsible List in HTML Without Java