title: jQuery append value of text field to list on form submit
body: <p>I'm trying to create an extremely simple comment form for a demo; add some text in a text field, submit, add value to a list. It works when I use a button and an on click event like so:</p>
  
  <pre><code>&lt;script&gt;
  $(".add-comment").click(function (e) {
  var add = $('#comment-body').val();
  $('.comments').append('&lt;li&gt;' + '&lt;h4&gt;Name&lt;/h4&gt; ' + add + '&lt;/li&gt;');
  });
  &lt;/script&gt;
  
  &lt;form&gt;
  &lt;input type="text" id="comment-body" /&gt;
  &lt;button type="button" class="add-comment"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  &lt;ol class="comments"&gt;&lt;/ol&gt;
  </code></pre>
  
  <p>But this is for a mobile demo, so I don't want a button at all. I just want the comment to be posted when the user hits the return key. I tried removing the button, and editing the script like so, but it doesn't work:</p>
  
  <pre><code>$("form").submit(function (e) {
  var add = $('#comment-body').val();
  $('.comments').append('&lt;li&gt;' + '&lt;h4&gt;Name&lt;/h4&gt; ' + add + '&lt;/li&gt;');
  });
  </code></pre>
  
  <p>Any ideas what I'm doing wrong?</p>