1

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.

Hef
  • 606
  • 6
  • 16
  • 1
    @pilchard Please read the question before flagging it. It's two very different cases, I have already mentioned that the method that you suggest does not work, because if does not detect line breaks caused by the size of the element. – Hef Dec 29 '20 at 23:59
  • This then, [How can I count text lines inside an DOM element? Can I?](https://stackoverflow.com/questions/783899/how-can-i-count-text-lines-inside-an-dom-element-can-i). You've posted the identical question twice. – pilchard Dec 30 '20 at 00:04

0 Answers0