-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom.html
More file actions
37 lines (33 loc) · 801 Bytes
/
dom.html
File metadata and controls
37 lines (33 loc) · 801 Bytes
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
</style>
</head>
<body>
<div class="container">
<p>
First jQuery!
</p>
<ul class="emphasis container">
<li>hello</li>
<li>hello1</li>
<li>hello2</li>
<li>hello3</li>
<li>hello4</li>
<li>
<ul>
<li>hello in the test</li>
</ul>
</li>
</ul>
</div>
<script src="jquery.js" type="text/javascript"></script>
<script>
//$('ul.emphasis').children('li').eq(2).next().text('added with jQuery'); 选择类为emphasis的ul的所有li孩子中的第三个,eq是从0开始计数的,然后选择下一个元素,把值改掉
console.log($('li').parent('.container')); //控制台输出li的所有父元素中类为container的元素
</script>
</body>
</html>