7. ERROR Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler


#1

Read through and can't see what's wrong. Probs typo but i'm not seeing it.

var main = function() {

$('.btn').click(function() {

var post = $('.status-box').val();
$('<li>').text(post).prependTo('.posts');

$('.status-box').val('');

$('.counter').text('140');
}); 

$('.status-box').keyup(function() {
var postlength = $(this).val().length;
var charactersLeft = 140 - postlength;
$('.counter').text(charactersLeft);

if(charactersLeft < 0) {
$('.btn').addClass('disabled');
}
else if(charactersLeft == 140) {
$('.btn').addClass('disabled');
}
else {
$('.btn').removeClass('disabled');
}
});

$('btn').addClass('disabled');

}
$(document).ready(main);


#2

Hi Cuddlyshark,

Take a close look at the error message:

$('.btn')

and your code:

Can you see the problem now?

Hint

You need a dot (.) before btn in your selector. Like so:

$('.btn')
// ↑ this


#3

Knew it would be something simple. Thanks a lot!


#4

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