<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Image Gallery</title>
<script src="./js/jQuery-2.2.0.min.js"></script>
<style>
</style>
</head>
<body>
<h1>things to do</h1>
<ol id="toDoList">
<li>mow the lawn</li>
<li>clean the windows</li>
<li>answer your email</li>
</ol>
<P id="toDoNotes" >make sure all these are completed by 8pm so you can watch the game on TV</P>
<script>
function countListItems(){
var olElement = document.getElementById("toDoList");
var count = 0 ;
for (var i=0;i<olElement.childNodes.length;i++){
if(olElement.childNodes[i].nodeType == 1)count++;
}
alert("The ordered list contains " + count + " items");
}
window.onload = countListItems;
</script>
</body>
</html>
全部评论
(0) 回帖