Download presentation
Presentation is loading. Please wait.
Published byGeraldine Ford Modified over 9 years ago
1
getElementById changes outside forms
2
From form to page Identified the field by using name Form.field Outside a form, use id Unique on the page Document(page).field
3
Retrieving the value In JavaScript document.getElementById("name").value What does that mean? document: the web page getElementById: find this id on the page Value: get the value of the object
4
Writing to the page Use an id on any element Replace the element using innerHTML Keeps the correct tags (meaning) in HTML
5
What to Write Generate HTML that you want. Concatenate literals and variables. Example: Build a paragraph using a variable called “content” document.getElementById(“id”).innerHTML = ‘ ’+content+’ ’;
6
CHANGING HTML General structure: document.getElementById(“id-name”).attribute document.getElementById(“id”).innerHTML document.getElementById(“id”).className document.getElementById(“id”).src
7
Changing class Highlighting when mouseover Requires that you change it back when you mouseout onmouseover= “document.getElementById(“id”).className=‘highlight’;” onmouseout= “document.getElementById(“id”).className=‘normal’;“
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.