Need help with Threadly


#1

It doesn't work. Can please someone put the full code up here?
Here is what i have:

Html:


    <form class="form">
      <input id="comment" type="text" placeholder="share your thoughts">
      <button type="submit" class="btn">post</button>
    </form>

    <ul class="comments">
      <li>Have you felt it?</li>
      <li>There has been an awakening.</li>
    </ul>

</div>

Js:

var main = function() {
$('form').submit(function() {

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

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

$('#comment').text("");

return false;

});
};

$(document).ready(main);


Threadly
#2

THis is a comented part - it doens't work either - but is a chance for me to see how this nice quotes functionality works.


#8

I don't know if they changed this but this is the beginning code you should start with. You may want to try resetting your project to see this code.

var main = function() {
$('form').submit(function() {

if(comment !== "") {
  var html = $('<li>').text(comment);

}

return false;

});
};

$(document).ready(main);

From that you can see that they give you the html variable and the comment variable. (Though technically I think you are right that the convention is to name your JQuery variables with the $ sign. So var $comment = $('#comment').val();

Then target your html variable and add the .prependTo() on it and you should be prepending it to your comments class for the li elements.
Once that is done you need to target your input for the comment and change its text from what was typed to be blank, which you already have correct, so leave that alone.