【问题标题】:Get the count of Checked check box using Jquery [duplicate]使用Jquery获取Checked复选框的计数[重复]
【发布时间】:2013-08-26 12:35:44
【问题描述】:

我想在代码示例下方获取选中复选框的数量,

谢谢, Digambar K.

【问题讨论】:

  • 请张贴html而不是图片
  • 实际代码比图像好得多。还是代码链接?

标签: javascript jquery checkbox


【解决方案1】:

首先,请在“代码”标签中发布实际代码,这样它就会出现在搜索结果中,对以后寻找相同问题的人有帮助。

另外,稍微用谷歌搜索一下就能马上找到答案:

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

【讨论】:

    【解决方案2】:

    您需要计算页面中的所有复选框吗?

    如果是:

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

    如果您只想计算表格内的复选框:

    $('table input[type=checkbox]:checked').length
    

    【讨论】:

      【解决方案3】:

      试试这个,

      $(function(){
          alert($('table').find('input[type="checkbox"]:checked').length)   
      });
      

      【讨论】:

        【解决方案4】:

        保持简单和愚蠢!

        试试这样的:

        // count all checkboxes
        var count = $(":checkbox").length();
        
        // count all checkboxes checked
        var countChecked = $(":checkbox:checked").length();
        

        【讨论】:

          【解决方案5】:

          将为您提供表格内所有已检查的输入

          $('.ms-input input[type=checkbox]:checked').length
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2011-02-09
            • 1970-01-01
            • 1970-01-01
            • 2017-09-24
            • 1970-01-01
            • 2014-05-06
            相关资源
            最近更新 更多