📜  javascript count no of lines - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:17.199000             🧑  作者: Mango

代码示例1
function getLinesCount(element) {
  var prevLH = element.style.lineHeight;
  var factor = 1000;
  element.style.lineHeight = factor + 'px';

  var height = element.getBoundingClientRect().height;
  element.style.lineHeight = prevLH;

  return Math.floor(height / factor);
}