jquery 全选和 获取所有选取的ID 组成的字符串用于拼接sql 全选

全选

[html]  view plain  copy
  1. function selectAll(obj) {  
  2.         if ($(obj).is(":checked")) {  
  3.             $("input[name='allCheck']").attr('checked', true);  
  4.         } else {  
  5.             $("input[name='allCheck']").attr('checked', false);  
  6.         }  
  7.     }  

获取ID

[html]  view plain  copy
  1. function getIds() {  
  2.         var ids = "";  
  3.         var checkClass = $("input[name='allCheck']:checked");  
  4.         checkClass.each(function() {  
  5.             ids+=$(this).val();  
  6.             ids+=",";  
  7.         });  
  8.         ids = ids.substr(0, ids.lastIndexOf(","));  
  9.         return ids;  
  10.     }  

猜你喜欢

转载自blog.csdn.net/fastjack/article/details/80655180