Skip to content

Commit 8117529

Browse files
committed
tianjia
1 parent 39ce5c2 commit 8117529

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

‎app/images1.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Image Gallery</title>
6+
<link rel="stylesheet" href="../css/layout.css" media="screen"/>
67
<script type="text/javascript" src="../js/images1.js" ></script>
78
</head>
89
<body>
@@ -22,5 +23,6 @@ <h1>Snapshots</h1>
2223
</li>
2324
</ul>
2425
<img src="" id="placeholder" alt="my image gallery" />
26+
<p id="description">Choose an image.</p>
2527
</body>
2628
</html>

‎css/layout.css‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
body{
2+
font-family: 'Helvetica','Arial',serif;
3+
color: #333;
4+
background: #ccc;
5+
margin: 1em 10%;
6+
}
7+
h1{
8+
color: #333;
9+
background: transparent;
10+
}
11+
a{
12+
color: #c60;
13+
background: transparent;
14+
font-weight: bold;
15+
text-decoration: none;
16+
}
17+
ul{padding: 0}
18+
li{
19+
float: left;
20+
padding: 1em;
21+
list-style: none;
22+
}
23+
img{
24+
display: block;
25+
clear: both;
26+
}

‎js/images1.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
function showPic(whichpic){
66
var source = whichpic.getAttribute("href");
77
var placeholder = document.getElementById("placeholder");
8+
var description = document.getElementById("description");
9+
var text = whichpic.getAttribute("title");
810

911
placeholder.setAttribute("src",source);
12+
description.firstChild.nodeValue = text;
13+
1014
}
1115
//计算body子元素数量
1216
function countBodyChildren(){
1317
var body_element = document.getElementsByTagName("body")[0];
1418
alert(body_element.childNodes.length);
1519
}
1620

17-
window.onload = countBodyChildren;
21+
//open 方法封装得方法
22+
function popUp(winURL){
23+
window.open(winURL,"popup","width=320,height=480");
24+
}
25+

‎js/index.js‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,36 @@ function getElementsByClassName(node ,classname){
3030
var paras = document.getElementsByTagName("p");
3131
for(var i=0;i<paras.length;i++){
3232
alert(paras[i].getAttribute("title"));
33-
}
33+
}
34+
35+
//DOM 常用属性
36+
//childNodes
37+
//nodeType
38+
//nodeValue
39+
//firstChild
40+
//lastChild
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+

0 commit comments

Comments
 (0)