I am designing my website and am struggling with typography. I would like to realize how many characters there are in each line of my paragraph div. Is there any way to do this with Javascript or jQuery?
For example: I have a 720px wide div with an 18px font size, how can I count how many characters there are for each line? If this is feasible I would also like to understand how to count the spaces or exclude them from the count.
I am currently using $("#mydiv p").text().length but it counts all characters and not characters for each line.
I appreciate any help and thank you for any replies.
document.write( $("#mydiv p").text().length );
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="mydiv" style="font-size: 18px; width: 720px; border: 1px solid red;">
<p>This is my div! This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!This is my div!</p>
</div>