Threadly - is it supposed to display the comments?


#1

I don't know if my code is correct! I think this is supposed to be a blog ...
So shouldn't the "comments field" stay populated?

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

    return false;
  });
};

$(document).ready(main);

#2

@h2obill,

Please re-edit your Post and add the corresponding HTML code.....

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697/2
[extra's]
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet


#3

Hi
I have just solved this.
In line 3 you choose the selector "#comments"; this should be "#comment" (the "comments" is a class and would be ".comments")
in line 6 you select the ID #html instead of the jQuery variable you created in line 5; so should read $(html) only.
hope this works for you.


#5

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