-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjqueryselectorDOM1.html
More file actions
75 lines (69 loc) · 1.83 KB
/
jqueryselectorDOM1.html
File metadata and controls
75 lines (69 loc) · 1.83 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<title>JQuery Selector Pseudoclass (DOM) - Faisal Dzulfikar</title>
</head>
<body>
<a href="index.html">BACK</a>
<br>
<button class="aksi1">Mencari elemen tertentu</button>
<button class="aksi2">Mencari elemen child</button>
<button class="aksi3">Mencari elemen lebih dari satu</button>
<button class="aksi4">Memilih elemen pertama atau elemen terakhir</button>
<button class="aksi5">Memilih elemen ganjil atau genap</button>
<script src="jquery.min.js"></script>
<ul id="destinations">
<li>child, child, nol, pertama</li>
<li>child, satu</li>
<ul>
<li>dua</li>
<li>tiga</li>
<li>empat</li>
<li>lima</li>
<li class="ambil1">genep, pilihan</li>
</ul>
<li>child, tujuh</li>
<li>child, salapan</li>
<li id="ambil2">child, sambilan, terakhir, pilihan</li>
</ul>
<script>
$(document).ready(function()
{
$(".aksi1").click(function()
{
$("#destinations li").css("background-color", "yellow");
});
});
$(document).ready(function()
{
$(".aksi2").click(function()
{
$("#destinations > li").css("background-color", "red");
});
});
$(document).ready(function()
{
$(".aksi3").click(function()
{
$(".ambil1, #ambil2").css("background-color", "orange");
});
});
$(document).ready(function()
{
$(".aksi4").click(function()
{
$("#destinations li:first").css("background-color", "blue");
$("#destinations li:last").css("background-color", "green");
});
});
$(document).ready(function()
{
$(".aksi5").click(function()
{
$("#destinations li:odd").css("background-color", "cyan");
$("#destinations li:even").css("background-color", "lime");
});
});
</script>
</body>
</html>