Page refreshes and my submit doesn't show


I have done this exercise and I checked with other answers here and it seems that it is correct. Although, when I write something and hit enter or click on post, the page refreshes instantly and shows nothing. Any help?

var main = function() {
  $('form').submit(function() {
    var comment = $("#comment").val();
    if(comment !== "") {
      var html = $('<li>').text(comment);
      $('#comment') = val('');
    return false;



Hi @quizan,

There are two small problems with your code:

  1. You shouldn't surround the html variable in a jQuery selector ($(...)), since it's not meant to select an element
  2. val() is a method you call on an element, like this: $(...).val("");, settting $('#comment') equal to whatever it returns won't work.

Fix those, and your code should work :slight_smile: Let me know if you have any more questions!


It worked like a charm! Thank you for your answer!


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.