js 每到达5次换一行
function getYourString(s) { var res = ''; var length = s.length; for (var i = 0, j = 1; i < length; i++, j++) { //每到达5次,添加一个换行标签 if (j && j % 6 == 0) { res += '<br />'; } else { res += s[i]; } } return res; } var test = '123456534545435435435'; document.write(getYourString(test));