Skip to content

Commit 187c981

Browse files
committed
take directory
1 parent b6af5dd commit 187c981

7 files changed

Lines changed: 70 additions & 3 deletions

File tree

‎app/images1.html‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Image Gallery</title>
6+
</head>
7+
<body>
8+
<h1>Snapshots</h1>
9+
<ul>
10+
<li>
11+
<a href="../images/Koala.jpg" title="a koala inside">Koala</a>
12+
</li>
13+
<li>
14+
<a href="../images/Lighthouse.jpg" title="a Lighthouse inside">Lighthouse</a>
15+
</li>
16+
<li>
17+
<a href="../images/Penguins.jpg" title="a Penguins inside">Penguins</a>
18+
</li>
19+
<li>
20+
<a href="../images/Tulips.jpg" title="a Tulips inside">Tulips</a>
21+
</li>
22+
</ul>
23+
</body>
24+
</html>

‎app/index.html‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
4-
<title></title>
4+
<meta charset="utf-8" />
5+
<title>Shopping list</title>
56
</head>
67
<body>
7-
8+
<h1>What to buy</h1>
9+
<p title="a gentle reminder">Don't forget to buy this stuff.</p>
10+
<ul id="purchases">
11+
<li>A tin of beans</li>
12+
<li class="sale">Cheese</li>
13+
<li class="sale">Milk</li>
14+
</ul>
15+
<script type="text/javascript">
16+
var items = document.getElementsByTagName("li");
17+
for(var i=0;i<items.length;i++){
18+
alert(typeof items[i]);
19+
}
20+
</script>
821
</body>
922
</html>

‎images/Koala.jpg‎

763 KB
Loading

‎images/Lighthouse.jpg‎

548 KB
Loading

‎images/Penguins.jpg‎

760 KB
Loading

‎images/Tulips.jpg‎

606 KB
Loading

‎js/index.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
/**
22
* Created by M.Jin on 14-7-1.
33
*/
4+
//dom操作中最常用的五个方法如下
5+
//document.getElementById();
6+
//document.getElementsByClassName();
7+
//document.getElementsByTagName();
8+
//document.getAttribute();
9+
//document.setAttribute();
10+
11+
//实现自己的getElementsByClassName()
12+
13+
function getElementsByClassName(node ,classname){
14+
if(node.getElementsByClassName){
15+
//使用现有方法
16+
return node.getElementsByClassName(classname);
17+
}else{
18+
var results = new Array();
19+
var elems = node.getElementsByTagName("*");
20+
for(var i=0;i<elems.length;i++){
21+
if(elems[i].className.indexOf(classname) != -1){
22+
results[results.length] = elems[i];
23+
}
24+
}
25+
return results;
26+
}
27+
}
28+
29+
//获取属性
30+
var paras = document.getElementsByTagName("p");
31+
for(var i=0;i<paras.length;i++){
32+
alert(paras[i].getAttribute("title"));
33+
}

0 commit comments

Comments
 (0)