//多余显示省略号 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].inn…
代码如下: <div style="width:100px;height:20px;text-overflow:ellipsis; white-space:nowrap; overflow:hidden; ">a b c d e f g h i j k l , msa sd sd sa w df f </div> text-overflow属性仅是注解,当文本溢出时是否显示省略标记.并不具备其它的样式属性定义.我们想要实现溢出时产生省略号的效果.还必须定义:强制…
1.js方法 function cutString(str, len) { //length属性读出来的汉字长度为1 if (str.length * 2 <= len) { return str; } var strlen = 0; var s = ""; for (var i = 0; i < str.length; i++) { s = s + str.charAt(i); if (str.charCodeAt(i) > 128) { strlen = strl…