DOM = document + object+model
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping List</title>
<style>
p {
color: yellow;
font-family: "arial", sans-serif;
font-size:1.2em;
}
body {
color:white;
background-color:black;
}
.special {
font-style:italic;
}
h2.special {
text-transform:uppercase;
}
#purchases {
border:1px solid white;
background-color:#333;
color:#ccc;
padding:1em;
}
#purchases li {
font-weight:bold;
}
</style>
</head>
<body>
<h1>what to buy</h1>
<h2 class="special">This is uppercase</h2>
<p title="a gentle reminder">Don't forget to buy this stuff.</p>
<ul id="purchases">
<li>A tin of beans</li>
<li class="special">Cheese</li>
<li >Milk</li>
</ul>
<!-- Mark-up goes here -->
<script src="file.js"></script>
</body>
</html>
<!-- alert(document.getElementsByTagName("*").length);
alert(document.getElementsByClassName("special").length);
var shopping = document.getElementById("purchases");
alert(shopping.getElementsByTagName("*").length);
function add(num1,num2) {
var total = num1*num2;
alert(3 == "3");
}
if(node.getElementsByClassName) {
return node.getElementsByClassName(classname);
} else {
var results = new Array();
var elems = node.getElementsByTagName("*");
for(var i=0; i<elems.length; i++) {
if(elems[i].className.indexOf(classname) != -1) {
results[results.length] = elems[i];
}
}
return results;
}
}
alert(shopping.getAttribute("title"));
shopping.setAttribute("title", "a list of goods");
alert(shopping.getAttribute("title"));