obj = document.getElementsByName("dk_tj"); var longtxt = ""; for (k in obj) { if (obj[k].checked) longtxt += obj[k].value + ','; } if (longtxt.length > 0) { longtxt = longtxt.substring(0, longtxt.length - 1); } console.log(longtxt);
打印成功,并且去掉末尾,号!!!