The Web Page Triad
- Declare variables
- Store and retrieve values
- Define and invoke functions
- Define your own classes
- Load and use external modules
- Write event handlers that respond to user and other events
- And much more
- The following selects all bold elements in the document and sets the color of the first one to red.
var elems = document.getElementsByTagName('b'); elems.style.color = 'red';
- Want to change the image in an img tag? The following associates an event handler for the click event of a button.
- Update the text content of a paragraph (p) element? Set the innerHTML property of the element as shown: