js 控制超出字数显示省略号
//多余显示省略号 function wordlimit(cname, wordlength) { var cname = document.getElementsByClassName(cname); for (var i = 0; i < cname.length; i++) { var nowLength = cname[i].innerHTML.length; if (nowLength > wordlength) { cname[i].innerHTML = cname[i].innerHTML.substr(0, wordlength) + '...'; } } };
//调用,description为class名
wordlimit('description', 30)