-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathjquery.html
121 lines (102 loc) · 4.01 KB
/
jquery.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<title>jQuery Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="app/lib/bootstrap/css/bootstrap.css"/>
<style type="text/css">
#display-area {
width: 550px;
height: 300px;
border: #339900 solid 1px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">jQuery Example</h1>
<div class="row">
<div class="col-md-6">
<div id="display-area">
</div>
</div>
<div class="col-md-6">
<!--button[id=btn$].btn.btn-success{$}$*6-->
<button id="btn1" class="btn btn-success">
1.
</button>
<button id="btn2" class="btn btn-success">
2.
</button>
<button id="btn3" class="btn btn-success">
3.
</button>
<button id="btn4" class="btn btn-success">
4.
</button>
<button id="btn5" class="btn btn-success">
5.
</button>
<button id="btn6" class="btn btn-success">
6.
</button>
</div>
</div>
</div>
<script src="app/lib/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
<script src="app/lib/bootstrap/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
var divArea = $('#display-area');
$('#btn1').click(function() {
divArea.text('Time : ' + new Date().getTime());
var btns = $('button');
console.log(btns);
console.log(btns.get(0), btns[0], btns.get(0) === btns[0]);
console.log(btns.get());
});
$('#btn2').click(function() {
var btns = $('button');
btns.each(function(i, e) {
$(this).val(i);
console.log(i, e === this, $(this));
});
btns.toggleClass('btn-success');
});
$('#btn3').click(function() {
var btns = $('button');
console.log(btns.first());
console.log(btns.first().next());
console.log(btns.last());
console.log(btns.parent().parent());
console.log(btns.parents('.row'));
console.log($('.row').children());
console.log(btns.first().next().siblings());
console.log(btns.first().end());
});
$('#btn4').click(function() {
var btns = $('button');
btns.html(function(i, v) {
return (v + 'button');
});
btns.val('vvv');
console.log(btns.val());
});
$('#btn5').click(function() {
console.log("", $(this).data('d1'));
$(this).data('d1', 1);
console.log("", $(this).data('d1'));
});
$('#btn6').click(function() {
var me = $(this);
var btns = me.prevAll();
console.log("", btns);
btns.toggle(500);
// btns.fadeOut(350);
});
$('#btn1').click();
});
</script>
</body>
</html>