Home >Web Front-end >JS Tutorial >Use js to solve the problem of numbers not being able to wrap into new lines_javascript skills

Use js to solve the problem of numbers not being able to wrap into new lines_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:21:401578browse
复制代码 代码如下:

function toBreakWord(intLen, id){
var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp =strContent.substr(0,intLen) "
";
strContent=strContent.substr(intLen,strContent.length); }
strTemp = strContent;obj.innerHTML=strTemp;
}

.br{word-break:break-all;word-warp:break-word;background-color:#eee;}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn