Here is the same example rendered in JavaScript.
View Source
to see how it works.