forked from yangxi0126/javaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkbox.html
48 lines (48 loc) · 1.25 KB
/
checkbox.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
.checkBoxClass{
display: none;
}
.checkBoxLabel{
background: url("images/UnCheck.png") no-repeat;
padding-left: 30px;
padding-top: 3px;
margin: 5px;
height: 25px;
width: 50px;
display: block;
cursor: pointer;
}
.checkBoxLabel:hover{
text-decoration: underline;
}
.checkBoxSelected{
background: url("images/Check.png") no-repeat;
}
</style>
</head>
<body>
<input id="checkbox1" class="checkBoxClass" type="checkbox"/>
<label for="checkbox1" class="checkBoxLabel">选项1</label>
<input id="checkbox2" class="checkBoxClass" type="checkbox"/>
<label for="checkbox2" class="checkBoxLabel">选项2</label>
</body>
<script src="js/jquery-1.9.1.min.js"></script>
<script>
$('.checkBoxClass').on('change',function(){
if($(this).is(':checked')){
$(this).next().addClass('checkBoxSelected');
}else{
$(this).next().removeClass('checkBoxSelected');
}
});
</script>
</html>