-
Notifications
You must be signed in to change notification settings - Fork 0
/
0911-11-traversing.html
51 lines (40 loc) · 1.29 KB
/
0911-11-traversing.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
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
<style>
.box {
font-size: 40px
}
</style>
</head>
<body>
<div class="box">box1</div>
<div class="box">box2</div>
<div class="box">box3</div>
<div class="box">box4</div>
<div class="box">box5</div>
<div class="box">box6</div>
<div class="box">box7</div>
<div class="box">box8</div>
<div class="box">box9</div>
<div class="box">box10</div>
<script>
// 原生js功能
// ●.even() - 選取第偶數個(從零開始計算)
$("div").even().css("color", "red");
// ●.odd() - 選取第奇數個(從零開始計算)
$("div").odd().css("color", "green");
// ●.eq() - 選取第 n 個
$("div").eq(3).css("color", "blue");
// ●.first() - 選取第一個
$("div").first().css("color", "lightblue");
// ●.last() - 選取最後一個
$("div").last().css("color", "orange");
</script>
</body>
</html>