首页> 实战笔录 >前端开发 >JQuery JQuery
获取 checkbox的 选中个数可以直接使用如下jquery语法
作者:小萝卜 2017-12-25 【 H5 jquery 】 浏览 1871
简介获取 checkbox的 选中个数可以直接使用如下jquery语法获取 checkbox的 选中个数可以直接使用如下jquery语法 $("input[type='checkbox']:checked").length;
获取 checkbox的 选中个数可以直接使用如下jquery语法
1
|
$( "input[type='checkbox']:checked" ).length; |
示例如下:
-
创建Html代码及css样式
1234567<
div
>
<
input
type
=
"checkbox"
name
=
"fruit"
> apple
<
input
type
=
"checkbox"
name
=
"fruit"
> orange
<
input
type
=
"checkbox"
name
=
"fruit"
> banana
<
input
type
=
"checkbox"
name
=
"fruit"
> watermelon
<
input
type
=
"button"
value
=
"I like these fruit!"
>
很赞哦! (0)