Disable the Button 1 ---Gimmee a hint


#1

I keep getting this error and I can't find my mistake. Outside should be below at the end, but nay.

<-- Oops, try again. Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handle -->

Below is my code:

 var main = function() {
$('.btn').click(function(){
    var post = $('.status-box').val();
    $('<li>').text(posts).prependTo('.posts');
});
   $('.status-box').keyup(function() {
    var postLength = $(this).val().length;
    var charactersLeft = 140 - postLength;
    $('.counter').text(charactersLeft);
});
   
$('.btn').click(function() {
  var post = $('.status-box').val();
  $('<li>').text(posts).prependTo('.posts');
  $('.status-box').val('');
  $('.counter').text('140');
});

if (charactersLeft < 0){ 
$('.btn').addClass('disabled');
}

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

else {
$('.btn').removeClass('disabled');
}
 });
 
$('.btn').addClass('disabled');

#2

Hi Art852456,

Your whole if/else if/else chunk of code belongs inside this part:

$('.status-box').keyup(function() {
  // ...
  // RIGHT HERE
});

Also, what's up with your two $('.btn').click(...);s?


#3

Who knows brother I'm trying hard to learn this, but it just hasn't clicked in my head yet. Thanks for the response.