I have an textarea with attribute wrap="hard", meaning I should be able to get the line break (new lines) after submit to server - this works. But what I wanna do is get the new lines that are created before submission.
Why? Because I wanna count the rows that are currently visible. And now I'm NOT talking about carriage return rows. I'm talking about rows that are created by limiting the width (or setting the cols attribute) of the textarea.
I have this textbox:
<textarea id="myarea" name="myarea" cols="35" rows="10" wrap="hard">
Some example text here. Hello my name is something I should be able to blabla.
</textarea>
Output in browser:
Some example text here. Hello my name is
something I should be able to blabla.
rows = 2
I've tried:
$('#myarea').html().split("\n").length
$('#myarea').val().split("< br>").length
$('#myarea').val().split("\r").length
And a few more combinations...
But none works. Is what I'm asking even possible without writing a script that counts each character and then creates a newline? I was hoping this would happend "automatically"...
If this is not possible, why can the server interpret (find) the new lines, while I can not?
Thanks!