復制代碼 代碼如下:
function toBreakWord(intLen, id){
var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length); }
strTemp+= strContent;obj.innerHTML=strTemp;
}
.br{word-break:break-all;word-warp:break-word;background-color:#eee;}