-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch.html
157 lines (133 loc) · 4.26 KB
/
switch.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>switch</title>
<style type="text/css">
.wrap .switch{
margin-top: 20px;
}
/*开关按钮样式*/
.onoffswitch {
position: relative;
width: 58px;
/*54,58修改开关样式*/
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 2px solid #1AB394;
border-radius: 3px;
}
.onoffswitch-inner {
display: block;
width: 200%;
margin-left: -100%;
-webkit-transition: margin 0.3s ease-in 0s;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before,
.onoffswitch-inner:after {
display: block;
float: left;
width: 50%;
height: 16px;
padding: 0;
line-height: 16px;
font-size: 10px;
color: white;
font-family: Trebuchet, Arial, sans-serif;
font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "是";
padding-left: 7px;
background-color: #1AB394;
color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "否";
padding-right: 7px;
background-color: #FFFFFF;
color: #919191;
text-align: right;
}
.onoffswitch-switch {
display: block;
width: 18px;
margin: 0px;
background: #FFFFFF;
border: 2px solid #1AB394;
border-radius: 3px;
position: absolute;
top: 0;
bottom: 0;
right: 36px;
-webkit-transition: all 0.3s ease-in 0s;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-switch {
right: 0px;
}
</style>
</head>
<body>
<div class="wrap" style="width: 100px;margin: 0 auto">
<div class="switch" data-keypoition="true" data-node="00050049">
<div class="onoffswitch">
<input type="checkbox" checked="true" class="onoffswitch-checkbox" id="example1">
<label class="onoffswitch-label" for="example1">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
<div class="switch" data-keypoition="true" data-node="00050049">
<div class="onoffswitch">
<input type="checkbox" checked="true" class="onoffswitch-checkbox" id="example2">
<label class="onoffswitch-label" for="example2">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<script type="text/javascript">
window.onload = function () {
checkClick();
};
function checkClick() {
var input = document.querySelectorAll('input');
var inputArr = [].slice.apply(input);
inputArr.forEach(function (value, index, arr) {
value.onclick = function () {
var value = this.checked;//获取checked值
console.log(value)
}
});
var input1 = document.querySelector('#example1');
input1.checked = false;//修改checked值
}
</script>
<script type="text/javascript" src="jquery.js"></script>
<!--<script type="text/javascript">
$(function () {
$('#example1').attr('checked',false);
$('input').on('click',function () {
console.log($(this).prop('checked'))
})
})
</script>-->
</body>
</html>