CPSC415A
Web Programming

Day 9 Notes

Modifying the DOM

Input Elements

<button id="addButton" type="button">Add</button>
<input type="text" id="inputText" />

var textBox = document.getElementById('inputText');
var text = textBox.value;

Modify DOM

var paragraph = document.createElement('p');
var textNode = document.createTextNode(text);
paragraph.appendChild(textNode);
document.body.appendChild(paragraph);
document.body.removeChild(paragraph);