Presentation is loading. Please wait.

Presentation is loading. Please wait.

GetElementById changes outside forms. From form to page  Identified the field by using name  Form.field  Outside a form, use id  Unique on the page.

Similar presentations


Presentation on theme: "GetElementById changes outside forms. From form to page  Identified the field by using name  Form.field  Outside a form, use id  Unique on the page."— Presentation transcript:

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’;“


Download ppt "GetElementById changes outside forms. From form to page  Identified the field by using name  Form.field  Outside a form, use id  Unique on the page."

Similar presentations


Ads by Google