Level 7- Remember to remove the class "disabled" from the Post button after the user starts typing


#1

I don't know what I've done wrong.

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

  • ').text(post).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'); 
    $('.status-box').keyup(function() {
        var postLength = $(this).val().length;
        var charactersLeft = 140 - postLength;
        $('.counter').text(charactersLeft);
    });

    };
    $(document).ready(main);


  • #2

    Hi Elle,

    You need to remove the disabled class from .btn inside your $('status-box').keyup(...); part as well, like this:

    $('.status-box').keyup(function() {
      // ...
      $('.btn').removeClass('disabled');
    });

    #3

    Thanks so much! It worked!