标签:函数 pre bst inner class str rgba rgb div
js代码:
1 function wordlimit(cname, wordlength) { 2 var cname = document.getElementsByClassName(cname); 3 for (var i = 0; i < cname.length; i++) { 4 var nowLength = cname[i].innerText.length; 5 if (nowLength > wordlength) { 6 cname[i].innerText = cname[i].innerText.substr(0, wordlength) + ‘...‘; 7 } 8 } 9 }; 10 wordlimit("类名",字数);//调用函数
标签:函数 pre bst inner class str rgba rgb div
原文地址:https://www.cnblogs.com/yshusen/p/14597266.html