Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以计算单行的字符数。假设我们有一个5行的段落,是否可以计算每行的字符数。到目前为止,我能找到的所有内容都计算了整个段落的字符数......
这应该工作
var lines = $("yourDiv").text().split("\n"); $.each(lines, function(n, elem) { console.log(elem.length); });