#javascript-code-04-dom.htm / htm
<html> <head> <title>Introduction to the DOM</title> <script> // We can't manipulate the DOM until the document // is fully loaded window.onload = function(){ // Find all the <li> elements in the document var li = document.getElementsByTagName('li'); // and add a ared border around all of them for ( var j = 0; j < li.length; j++ ) { li[j].style.border = '1px solid #000'; } // Locate the element with an ID of 'everywhere' var every = document.getElementById( "everywhere" ); // and remove it from the document every.parentNode.removeChild( every ); }; </script> </head> <body> <h1>Introduction to the DOM</h1> <p class="test">There are a number of reasons why the DOM is awesome, here are some:</p> <ul> <li id="everywhere">It can be found everywhere.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> </ul> </body> </html>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.