Remember to prepend a new li element inside the event handler


#1

Hello people, please help have a look at my code;

var main = function() {
$('.btn').click(function() {
var post = $('.status-box').val();
$('').text(post).prependTo('.posts');

});
}

And this is the error am getting;

"Oops, try again. It looks like the Post button didn't add a new message. Remember to prepend a new li element inside the event handler."


#2

Hi
you forgot to specify to what you want to add the text, i.e. the li :

$('<li>').text(post).prependTo('.posts');

without the <li>, you add something to the <ul> with the class posts but we do not know what


#3

i added the li but its still giving thesame error.


#4

I am having the same problem

var main = function(){
$('.btn').click(function(){
var post = $('.status-box').val();
$('<li>').text(post).prependTo('.posts');
});
}


#5

@pyrunner24721 You need to call main on $(document) ready(). Look through the first and second exercises of this section if you need help with that :slight_smile:

@cortehz I think you have the same problem as @pyrunner24721.


#6

Thanks @zystvan, silly beginners error


#7

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