文章源头:http://www.cnblogs.com/td960505/p/6123510.html

以下为使用JQuery获取input checkbox被选中的值代码:

<html>
    <head>
        <meta charset="gbk">
        <!-- 引入JQuery -->
        <script src="jquery-1.3.1.js" type="text/javascript"></script>
    </head>

<body>
        <input type="checkbox" value="橘子" name="check">橘子1</input>
        <input type="checkbox" value="香蕉" name="check">香蕉1</input>
        <input type="checkbox" value="西瓜" name="check">西瓜1</input>
        <input type="checkbox" value="芒果" name="check">芒果1</input>
        <input type="checkbox" value="葡萄" name="check">葡萄1</input>
        
        <input type="button" value="方法1" id="b1">
        <input type="button" value="方法2" id="b2">

</body>
    
    <script>
        //方法1
        $("#b1").click(function(){
            //$('input:checkbox:checked') 等同于 $('input[type=checkbox]:checked')
            //意思是选择被选中的checkbox
            $.each($('input:checkbox:checked'),function(){
                window.alert("你选了:"+
                    $('input[type=checkbox]:checked').length+"个,其中有:"+$(this).val());
            });
        });
        
        //方法2
        $("#b2").click(function(){
            $.each($('input:checkbox'),function(){
                if(this.checked){
                    window.alert("你选了:"+
                        $('input[type=checkbox]:checked').length+"个,其中有:"+$(this).val());
                }
            });
        });
    </script>
</html>

JQuery获取被选中的checkbox的value值的更多相关文章

  1. 使用JQuery获取被选中的checkbox的value值 以及全选、反选

    以下为使用JQuery获取input checkbox被选中的值代码: <html> <head> <meta charset="gbk"> & ...

  2. 使用JQuery获取被选中的checkbox的value值

      上网查了一下,感觉一些人回答得真的是不知所云,要么代码不够简便.或者是有些想装逼成分等. 以下为使用JQuery获取input checkbox被选中的值代码: <html>    & ...

  3. jquery获取所有选中的checkbox的ID

    //获取所有选中的CheckBox的id function getCheckBox() { var spCodesTemp = ""; $("input:checkbox ...

  4. jquery获取所有选中的checkbox

    获取所有name为spCodeId的checkbox var spCodesTemp = "";       $("input:checkbox[name=spCodeI ...

  5. jQuery获取radio选中后的文字

    原文链接:http://blog.csdn.net/zhanyouwen/article/details/51393216 jQuery获取radio选中后的文字转载 2016年05月13日 10:3 ...

  6. element ui 表格提交时获取所有选中的checkbox的数据

    <el-table ref="multipleTable" :data="appList" @selection-change="changeF ...

  7. jq获取被选中的option的值。jq获取被选中的单选按钮radio的值。

    温故而知新,一起复习下jq的知识点. (1) jq获取被选中的option的值 <select id="select_id"> <option value=&qu ...

  8. jQuery获取Select选中的Text和Value,根据Value值动态添加属性

    语法解释:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var chec ...

  9. jQuery获取Select选中的Text和Value,根据Value值动态添加属性等

    语法解释:1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发2. var ch ...

随机推荐

  1. 在服务器搭建Jupyter notebook

    安装 Jupyter Notebook (这里虽然是对centos和Python2的,但是在Ubuntu16.04,Python3同样可以照着弄) Jupyter Notebook 简介 Jupyte ...

  2. 如何在DBGrid中能支持多项记录的选择

    When you add [dgMultiSelect] to the Options property of a DBGrid, you give yourself the ability to s ...

  3. STL Queue 容器

    STL Queue 容器 Queue简介         queue是队列容器,是一种“先进先出”的容器.         queue是简单地装饰deque容器而成为另外的一种容器.        # ...

  4. Navicat使用教程:获取MySQL中的行数(第1部分)

    下载Navicat Premium最新版本 Navicat Premium是一个可连接多种数据库的管理工具,它可以让你以单一程序同时连接到MySQL.Oracle及PostgreSQL数据库,让管理不 ...

  5. MongoDB ShardingCluster

    sharding集群中的组件: 1.mongos:router,可以通过keepalived实现高可用. 2.config server:元数据服务器,这里要借助zookeeper存放配置信息. 3. ...

  6. Hbase—— rowkey 过滤器(rowfilter)

    1.RowFilter 提取rowkey以01结尾数据Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new RegexStri ...

  7. 解题:APIO/CTSC 2007 数据备份

    题面 用双向链表把相邻两项的差串起来,用大根堆维护价值,每次贪心取最大的$x$.取完之后打标记删掉$pre[x]$和$nxt[x]$,之后用$val[pre[x]]+val[nxt[x]]-val[x ...

  8. 【堆的启发式合并】【P5290】[十二省联考2019]春节十二响

    Description 给定一棵 \(n\) 个节点的树,点有点权,将树的节点划分成多个集合,满足集合的并集是树的点集,最小化每个集合最大点权之和. Limitation \(1~\leq~n~\le ...

  9. bootstrap.yml与application.yml的区别

    说明:其实yml和properties文件是一样的原理,主要是说明application和bootstrap的加载顺序.且一个项目上要么yml或者properties,二选一的存在. Bootstra ...

  10. python 中的os模块

    python os模块   Python os 模块提供了一个统一的操作系统接口函数 一.对于系统的操作 1.os.name 当前使用平台 其中 ‘nt’ 是 windows,’posix’ 是lin ...