CIS 119 - Choosing a specific page element
Objectives
- select and modify a specific page element
document.getElementById
- there are a couple of easy ways to work with a specific element
- place JavaScript code in the element's opening tag as the value of an event handler
- give the element an id value and use the document.getElementById method to access that element
- using getElementById lets you remove JavaScript code from being part of the content of the page
- see onclick1.html for an example of inline JavaScript
- see onclick2.html for equivalent JavaScript using document.getElementById
- libraries such as jQuery greatly expand the ability to locate specific elements or a set of elements