Javascript Dom
Javascript Dom
and Collections
} document.getElementById("myAnchor").
getAttribute("target");
} document.getElementById("myAnchor").
setAttribute("href",
"http://www.w3schools.com");
©1992-2012 by Pearson Education, Inc. All
Rights Reserved. 7
<!DOCTYPE html><html>
<head>
<script>function myFunction() {
document.getElementById("myAnchor").setAttribute("href"
, "http://www.w3schools.com");}
</script></head>
<body>
<a id="myAnchor">A Link: Go to w3schools.com</a>
<p>Click the button to set the href attribute with a
value of "www.w3schools.com" of the a element
above.</p>
<button onclick="myFunction()">Try it</button>
<p><strong>Note:</strong> Internet Explorer 8 and
earlier does not support the setAttribute method.</p>
</body></html>
After
clicking
para.appendChild(node);
</script></head>
<body>
<div id="div1"><p id="p1">This is a paragraph.</p>
<p id="p2">This is another paragraph.</p></div>
</body></html>
After
clicking
<script>function myFunction() {
var list = document.getElementById("myList");
list.removeChild(list.childNodes[0]);}</script>
</body></html>
After
clicking