Notes by P. Conrad for CISC103, Univ. of DE, Fall 2005
You make a web page that two kinds of elements:
A five-step plan for simple use of dynamic HTML
When some event happens, for example:
Typically, you write a function that changes the element. For example, suppose you had this exam question:
Write a function called July4thGreeeting() that:
|
Such a function might look like this:
function July4thGreeting() |
Two things you can do with a span tag or div tag:
That will most certainly be on the final exam.
If you look at the source code for this document, dynHTML.html, you'll see five global variables. The first two global variables are "arrays". In this case, they are arrays of string literals. The first array, colors
, contains a list of color names. These color names need to be legal colors names for CSS properties. (A list of those color names is in one of the appendices of Deitel/Deitel/Goldberg book.)
The other array contains a list of synonyms for the word "change".
var colors = [ "red", "green", "blue", "purple", "black", "brown", "orange", "darkgray"]; var differentTexts = ["change", "become different", "morph into something else","mutate", "put on a new face","remake themselves"]; var curColor = 0; var curText = 0; var secondCounter = 1; |