How to hide and show elements with JavaScript (updated)

There are times that we just want  to hide an element first, and shows it later when the user performs something like clicking on a button.

Using Hardcoded JavaScript

Implementing this functionality with JavaScript is quite easy. ( There is a really great section on Embedding JavaScript in HTML in book  JavaScript: The Definitive Guide: Activate Your Web Pages. If you don’t have that book, you really should.)
The strategy is to place the controlled element on a hidden layer (div), and then change the display attribute to make it show up.

First, Let’s define a variable, which tells if the video should be shown, in JavaScript.
Continue reading “How to hide and show elements with JavaScript (updated)”