Here is an example:
<div><span style="font-size:15px;">some text here which is </span>
<span style="color:red;">split automatically by the browser.</span></div>
which the browser renders as (with styles of course):
some text here which is split
automatically by the browser.
I am building up a javascript application which has to understand the last word in each line (split
in this case). Currently I am using the CSS white-space
property to deal with overflow text. Therefore, the browser will not give me a clue about where it does break the line. So, what would be a nice function to understand the last word in each line?
EDIT
I am using pure-javascript, so jQuery would not be an option and the white-space
property is applied to the div
. So actually, think the div
as a line renderer.