按照width截取字符串
]/** * 按照width截取字符串 */function cutstr(source, width) {var el = document.createElement("span");el.style.display = "none";document.body.appendChild(el);var span = $(el), s = "";for (var i = 0, len = source.length; i < len; i++) {span.text(span.text() + source.charAt(i));if (span.width() > width) {s = span.text();break;}}span.remove();span = null;return s ? s + "..." : source;};