jquery获取checkbox 选中的值

  1. <ul id="reason_ul">
  2. <input name="reason" type="checkbox" value="1"><span>产品使用一段时间后不工作了</span>
  3. <input name="reason" type="checkbox" value="2"><span>产品一收到就是坏的</span>
  4. <input name="reason" type="checkbox" value="3"><span>产品不能开机或自己启动</span>
  5. <input name="reason" type="checkbox" value="4"><span>产品不能充电</span>
  6. <input name="reason" type="checkbox" value="5"><span>产品外观非人为改变</span>
  7. <input name="reason" type="checkbox" value="6"><span>产品的内部或外部的损坏</span>
  8. <input name="reason" type="checkbox" value="7"><span>其他</span>
  9. </ul>

jquery代码


  1. function do_submit() {
  2. var reason_arr = new Array();
  3. $.each($("input[name='reason']"), function(){
  4. if(this.checked){
  5. reason_arr[i] = $(this).val();
  6. }
  7. });
  8. var vals = reason_arr.join(",");
  9. console.log(vals);
  10. }

jquery获取checkbox 选中的值

相关推荐