【问题标题】:find if any checkbox is checked in a specific column of the GridView using jQuery使用 jQuery 查找是否在 GridView 的特定列中选中了任何复选框
【发布时间】:2010-08-27 17:41:37
【问题描述】:

请告诉我如何使用 jQuery 检查是否在 GridView 控件的特定列(例如第一列)中选中了任何复选框?其他列中也有复选框,但我需要检查是否在特定列中选中了任何复选框。提前致谢。

【问题讨论】:

    标签: asp.net jquery gridview


    【解决方案1】:

    感谢您的回复。在以下链接的帮助下自己解决了这个问题

    if ($("#<%=GridView1.ClientID %> >tbody >tr >td:first-child > input[type=checkbox]:checked").length > 0) {}
    

    http://www.codedigest.com/CodeDigest/63-Check-All-Checkboxes-in-a-Particular-Column-in-GridView-using-JQuery-.aspx

    【讨论】:

    • 是的,这与我的第一个解决方案相同。
    【解决方案2】:

    你可以这样做:

    var checked = $('selectorForColumn :checkbox:checked').length > 0;
    

    或者这个:

    var checked = $('selectorForColumn :checkbox').is(':checked');
    

    ...如果列中至少有一个复选框被选中,它将返回true

    在没有看到你的标记的情况下不确定正确的选择器是什么,但如果它是第一列,你会做这样的事情:

    $('table > tbody > tr > td:first-child :checkbox')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-04
      • 2016-03-04
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 2016-06-12
      • 2011-01-13
      相关资源
      最近更新 更多