获取table中CheckBox选中行的id

方式一

 

var selectList='';

jQuery(".table tbody input[type=checkbox]:checked").map(function () {

var id = jQuery.trim(jQuery(this).closest("tr").find("td:eq(0)").text());
 selectList+=id+',';

})

selectList=selectList.substring(0,selectList.length-1);

此方式的第一列是ID列

方式二

 

var selectList = jQuery(".table tbody input[type=checkbox]:checked").map(function () {

return jQuery(this).val();

}).get().join(',');

此方式需要将ID值作为CheckBox的value值

好处是不需要手动将每一个ID值加到字符串中

 

posted @ 2017-10-25 17:10  流年sugar  阅读(6996)  评论(0编辑  收藏  举报