forked from jackfrued/Python-100-Days
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery01.html
77 lines (77 loc) · 1.61 KB
/
jquery01.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#page ul li {
list-style: none;
width: 240px;
height: 40px;
text-align: center;
border-bottom: 1px solid darkgray;
background-color: darkcyan;
color: white;
font: 18px/40px Arial;
}
#data {
border-collapse: collapse;
}
#data td {
border: 1px solid black;
}
</style>
</head>
<body>
<div id="page">
<h1 id="header">List</h1>
<h2>Buy groceries</h2>
<ul>
<li id="one" class="hot"><em>fresh</em> <em>figs</em></li>
<li id="two" class="hot">pine nuts</li>
<li id="three" class="hot"><span>honey</span></li>
<li id="four">balsamic vinegar</li>
</ul>
<table id="data">
<tr>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
<td>Item 5</td>
</tr>
<tr>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
<td>Item 5</td>
</tr>
<tr>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
<td>Item 5</td>
</tr>
</table>
<button id="clearBtn">清空表格</button>
</div>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$('#page li:gt(0)').on('click', function(evt) {
$(evt.target).remove();
});
$('#page li:even').css({
'background-color': 'coral',
'font-size': '36px'
});
$('#page li:odd').css('background-color', 'pink');
$('#clearBtn').on('click', function() {
$('#data').empty();
});
});
</script>
</body>
</html>