Web Design: JavaScript toggle
The tutor continues from yesterday’s example of dynamic content.
In yesterday’s post I discussed how to change an element’s appearance on a page with JavaScript. Today, I’ll discuss how to change it back and forth.
This paragraph’s style can be toggled back and forth.
The mechanism of the toggle is a JavaScript if statement:
var x = document.getElementById(“element”).style;
if (x==”teal”){
back to normal
}
else{
change color to teal, background to yellow, font size, etc
}
Source:
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.
Leave a Reply
You must be logged in to post a comment.