Can someone help me figure out how to accurately determine the number of lines in a div? I tried using this example on jsfiddle, but it's giving me 9 instead of 5. Any suggestions on what might be causing this discrepancy?
var lines = document.getElementById('ptest').textContent;
alert(lines.split(/\r\n|\r|\n/).length);
Also, would like to use this code to count the number of lines in a paragraph. Any insights on how to achieve this?