5. Count characters left


#1

I keep getting this message
'Oops, try again.
Remember to update the '.counter' to show how many characters are left'
But I cant see whats wrong, can you please help me?

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

').text(post).prependTo('.posts');
$('.status-box').val('');
});
$('.status-box').keyup(function() {
var postLength = $(this).val().length;
var charactersLeft = 140 - postLength;
$('.counter').text(charactersLeft);
});
}
$(document).ready(main);


#2

@christina.bruun
Before getting ready your main function, end your variable main with a semicolon. Look also at this part;


Is there an error to ('.posts')where you put an additional s?


#3

@miniapple8888 Sorry, but no - both of your suggestions are incorrect.


@christina.bruun Your code is fine, please try refreshing the page or switching browsers.


#4

It looks right with one exception: Under var post = $('.status-box).val(); you need to create a new 'li' attribute to append the new message in. The next line should look like $('<li>').text(post).prependTo('.posts');


#5

A post was split to a new topic: My code doesn't work on exercise 5


#6