I have a task going on in which I need to reading the text within a p tag line by line (one line at a time). The p tag is contained within a div tag that has an id too. How can I read the text within the p tag one line at a time in JavaScript. I have tried the following, but it didn't help:-
var text = document.getElementById('wrap');
var lines = text.innerHTML.split('\n');
The HTML does not contain any "\n" characters. When ever the line exceed the width of the div the content of the p tag goes to the next line. I want to read the whole content of this p tag on line at a time. That is the first element of the lines array is the first line of the content as seen in the browser and the second element is the second line and so on.