title: How to get the number of lines in a textarea?
body: <p>What I would like is to count the number of lines in a textarea, e.g:</p>
  
  <pre><code>line 1
  line 2
  line 3
  line 4
  </code></pre>
  
  <p>should count up to 4 lines. Basically pressing enter once would transfer you to the next line</p>
  
  <p>The following code isn't working:</p>
  
  <pre><code>var text = $("#myTextArea").val();   
  var lines = text.split("\r");
  var count = lines.length;
  console.log(count);
  </code></pre>
  
  <p>It always gives '1' no matter how many lines.</p>