jquery 一句话实现全选和不全选js
JavaScript部分:
1
2
3
|
function checkAll(obj){
$("#box input[type='checkbox']").prop('checked', $(obj).prop('checked'));
}
|
html部分:
1
2
3
4
5
6
7
8
9
10
11
12
|
<
div
id
=
"box"
>
<
input
type
=
"checkbox"
onclick
=
"checkAll(this)"
>全选<
br
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
<
input
type
=
"checkbox"
><
br
>
</
div
>
|