I have an element inside my website that is supposed to only show some lines of a string, depending on the size of the element, and size of the screen. In order to do that I need to know how many line breaks I have inside the text that is inside this element.
I have tried element.textContent.match(/\n/g)
, but this doesn't work and returns null
, since it doesn't detect line-breaks that are caused by the size (width) of the element.