码迷,mamicode.com
首页 > 其他好文 > 详细

获取table中CheckBox选中行的id

时间:2017-10-25 18:03:08      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:box   获取   选中行   select   sele   方式   字符串   input   string   

方式一

 

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值加到字符串中

 

获取table中CheckBox选中行的id

标签:box   获取   选中行   select   sele   方式   字符串   input   string   

原文地址:http://www.cnblogs.com/sugarwxx/p/7729948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!