forked from hjskevin/js-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpic.html
46 lines (46 loc) · 1.85 KB
/
pic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>图片库</title>
<style type="text/css" media="screen">
body{font-family:"Helvetica","Arial" ,"serif";color:#333;background-color:#ccc;margin: 1em 10%;}
h1{color:#333;background-color: transparent;}
a{color: #c60;background-color: transparent;font-weight: bold;text-decoration: none;}
ul{padding: 0;}
li{float: left;padding: 1em;list-style: none;}
img{display: block;clear: both;}
</style>
</head>
<body>
<h1>这是一个图片库</h1>
<ul>
<li><a href="images/bg1.jpg" onclick="showPic(this);return false;" title="图片1">图片1</a></li>
<li><a href="images/bg2.jpg" onclick="showPic(this);return false;" title="图片2">图片2</a></li>
<li><a href="images/bg3.jpg" onclick="showPic(this);return false;" title="图片3">图片3</a></li>
<li><a href="images/bg4.jpg" onclick="showPic(this);return false;" title="图片4">图片4</a></li>
</ul>
<img src="images/bg1.jpg" alt="bg" id="placeholder" width="300" height="200">
<p id="description">Choose an images:</p>
<script type="text/javascript">
function showPic(whichpic){
var source=whichpic.getAttribute("href");
var text=whichpic.getAttribute("title");
var description=document.getElementById("description")
var placeholder=document.getElementById("placeholder");
placeholder.setAttribute("src",source);
description.firstChild.nodeValue=text;
}
// function countBodyChildren(){
// var body_element=document.getElementsByTagName("body")[0];
// alert(body_element.childNodes.length);
// }
function countBodyChildren(){
var body_element=document.getElementsByTagName("body")[0];
alert(body_element.nodeType);
}
window.onload=countBodyChildren;
</script>
</body>
</html>