1

I have fixed width div with a long text inside. How can I get lines of a text which are the result of word wrapping? In the attached snippet I want to get an array with two strings: ['Lorem Ipsum. Lorem Ipsum.', 'Lorem Ipsum.'].

console.log(document.getElementById('target').innerText)
<div id="target" style="width: 200px">Lorem Ipsum. Lorem Ipsum. Lorem Ipsum.</div>
Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
Alex
  • 1,724
  • 13
  • 25

0 Answers0