-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path复习jq.html
120 lines (111 loc) · 3.2 KB
/
复习jq.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="js/jquery-3.1.0.js"></script>
<script>
$(function(){
var divs = $("div");
$(divs).each(function(index,cur){
$(cur).html("当前是第"+(index+1)+"个div");
if((index+1)%2!==0){
$(cur).addClass("ji");
}else{
$(cur).addClass("ou");
}
})
var imgs = $("img");
console.log($("img").get().reverse());
console.log($(".three").index());
$("#one").click(function(){
$(this).data("greeting",{
"name":"胡龙超",
"number":"20130502047",
"age":"21",
"sex":"男"
})
})
$("div:eq(1)").click(function(){
console.log($("#one").data("greeting").name);
})
//移除img上的src属性
//$("img:eq(1)").removeAttr("src");
$("div:last").click(function(){
$("input[type='checkbox']:eq(1)").prop({"checked":"true"});
var offset = $(this).offset();
console.log("左:"+offset.left+" 上:"+offset.top);
$("div:even").offset({"left":"80"});
$(".total").scrollTop(2000);
})
$("input[type='button']:first").click(function(){
$(".total").height(function(n,c){
return c+10;
})
})
$("input[type='button']:last").click(function(){
alert("1");
$(".t1").animate({"left":"50"},1000);
/*$(".total").width(function(n,c){
return c+10;
})*/
})
console.log($("p.t1"));
})
</script>
<style>
.ji{
background-color: aqua;
}
.ou{
background-color: deepskyblue;
}
img{
width: 50%;
}
.total{
width: 500px;
height: 100px;
background-color: skyblue;
}
.t1{
width: 200px;
height: 50px;
background-color: deeppink;
}
.t2{
background-color: red;
}
</style>
</head>
<body>
<img src="img/140-15052G62G1-50.jpg" />
<img src="img/140-15052G62G1.jpg" />
<div id="one"></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<ul>
<li class="one">1</li>
<li class="two">2</li>
<li class="three">3</li>
</ul>
<input type="datetime" />
<input type="checkbox" />
<input type="checkbox" />
<input type="email" />
<input type="button" value="变高" />
<input type="button" value="变宽" />
<ul class="total">
<p class="sub">很好看</p>
</ul>
<p class="t1">t1</p>
<p class="t2">t2</p>
</body>
</html>