Programming Exercise

Put an image on your web page. Move it or hide it randomly from time to time. (Your TA should demonstrate an example.)

Changing Text on Web Page

To modify text on a web page you have to find the text. By adding an ID to the HTML tag, you can make the text easy to search. For example, the HTML file in the base code replaced <h2>About</h2> (a typical HTML heading) with <h2 id="about">About</h2> (the same heading, but now with an ID attribute with value “about”).

Some useful functions and methods for working with ID’s and text:

var anElem; – declare a global variable to contain a document element

anElem = document.getElementById("about"); – search by ID for name “about”

anElem.style.color = "red"; – set the color attribute of a text element