Hi everyone, I'm trying to solve Jquery Projects - Threadly. When i input the text, it does not show up in the list. any solutions? Thanks.

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

    return false;



Hey Albert,

$('.comment') selects an element with the class="comment" attribute. You need to select the comment id. Do you know how to do that?


With jQuery, you can select an id like this:

//  ↑ this gets replaced by the actual id (in this case, it's `comment`)


var comment = $('.comment').val();
should be var comment = $('#comment').val();

can be html.prependTo('ul.comments');
It doesn't have to be but it is more specific.

$('.comment').val() = "";
should be $('.comment').val("");


2 posts were split to a new topic: Need help with Threadly


var $html = $('#comment').val(); should be var html = $('

  • ').text(comment); since your populating a li tag with the var comment which contains the comment text.

    html.prependTo('ul.comments'); is a more specific version of your $html.prependTo('.comments'); line which just makes sure the code is going to the right place.

    lastly $('#comment').val(""); should be inserted into your if statement because it causes the comment input to clear after the comment has been posted.

    Here is the code all together

    > if(comment !== "") {
    >       var html = $('<li>').text(comment);
    >       html.prependTo('ul.comments');
    >       $('#comment').val("");
    >     }