使用$.each(function(){});能夠獲得checkbox 中對應的值, ajax
在ajax上傳的時候須要把 traditional 設置爲 true post
$('.but_delet_choice').click(function(){ var $check_boxes = $('input[type=checkbox][checked=checked][id!=check_all_box]'); if($check_boxes.length<=0){ alert('您未勾選,請勾選!');return; } if(confirm('您肯定要刪除嗎?')){ var dropIds = new Array(); $check_boxes.each(function(){ dropIds.push($(this).val()); }); $.ajax({ type:'post', traditional :true, url:'${ctx}/discuss/dropMoreRmb', data:{'dropIds':dropIds}, success:function(data){ refreshRmb(1); } }); } return false; });