Simple DOM Exercise [Aug. 19, 2011, 10:35 a.m.]
Write a function called by clicking a button on a page to alert
(1) the number of links on the page and
(2) the first and last of these links
(An answer is at http://jsbin.com/oweri3/edit)
SIMPLE DOM INSERTION EXERCISE
//this function takes 3 arguments and
//must have an id already established
//on an element within your HTML
function insertion(el,id,text){
var parent = document.getElementById(id);
var newEl = document.createElement(el);
var txt = document.createTextNode(text);
var pasteEl = parent.appendChild(newEl);
pasteEl.appendChild(txt);
};
//the call to the function
insertion('p', 'top', 'inserted child text node');