首页> 实战笔录 >前端开发 >JQuery JQuery

获取 checkbox的 选中个数可以直接使用如下jquery语法

作者:小萝卜 2017-12-25 浏览 1621

简介获取 checkbox的 选中个数可以直接使用如下jquery语法获取 checkbox的 选中个数可以直接使用如下jquery语法 $("input[type='checkbox']:checked").length;

获取 checkbox的 选中个数可以直接使用如下jquery语法

1
$("input[type='checkbox']:checked").length;

示例如下:

  1. 创建Html代码及css样式

    1
    2
    3
    4
    5
    6
    7
    <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)

文章评论

    高端网站建设