7. Disable Button 1


#1

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').removeClass('disabled');
  }
  else {
      $('.btn').removeClass('disabled'); 
  }      
});

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

$(document).ready(main);

I have no idea what I have done wrong....im just endlessly staring at this


#2

Hi Kylerausch4,

This seems to be caused by another really small typo :)
Take a look at this line:

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

Can you see what's wrong in there? It's a little harder to spot than the unclosed single quote (') from your last question :)

Hint

 $(.'btn').removeClass('disabled');
// ↑ the dot (`.`) belongs *inside* the quotes ;)


#3

I fixed the misplaced ( ' ) but unfortunately it still gives me "Oops, try again. Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler"

I appreciate all your help by the way....I am not the strongest with my coding just yet

Cheers

Kyle


#4

@kylerausch4 Sorry, I missed the other problem in your code. There's also an unnecessary closing curly brace (}) on line 12 that should be removed :)