checkbox复选框,获取多个选中的数据

本次是以Jquery实现。

<inout name="checkeName" type="checkbox"  value="abc"> </input>

// 获取选中框的value

var abcs = [];

$('input :checkbox[name=checkName] : checked').each(function(){

  abcs.push($(this).val());

  // $(this).parents('tr').children().eq(1).html();    // 这个行代码中数字 1 代表获取复选框后的第一个td数据

});

checked :已选中

input :checkbox[name=checkName] : checked  : 获取已选中的name为:checkName的input标签

$(this).val():获取选中后的value

abcs.push():将获取选中的数据以数组形式存入

// 获取tr中某个td的数据

$(this).parents('tr').children().eq(1).html();    // 这个数字 1 代表获取复选框后的第一个td数据

 

posted @ 2020-07-08 09:06  comliang  阅读(2682)  评论(0)    收藏  举报