当前位置: 代码迷 >> 综合 >> jquery获取所有checkbox选中值,并串联成字符串(兼容IE8-FF)
  详细解决方案

jquery获取所有checkbox选中值,并串联成字符串(兼容IE8-FF)

热度:24   发布时间:2024-01-21 03:18:50.0
 function GetCheckboxvalues() {var optIDs = '';jQuery("input:checkbox[name='OperationID']:checked").each(function() { optIDs += this.value + ','; }); //遍历,用逗号串联 alert(optIDs);          }


还有一种是利用数组函数处理字符串

function GetCheckboxvalues() {var optIDs = new Array();jQuery("input:checkbox[name='OperationID']:checked").each(function() { optIDs.push(this.value); }); //遍历,用逗号串联 alert(optIDs.join(','));          }



  相关解决方案