Oops, try again. Make sure you have defined all the variables!


#1

Hello all, I've been on disable button 1 for two days now i can't figure out what i'm doing wrong please help?
thanks,
Drew

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(characterLeft < 0) {
        $('.btn').addClass('disabled');
    }
    else if(charactersLeft == 140) {
        $('.btn').addClass('disabled');
    }
    else {
        $('.btn').removeClass('disabled');
    }
});

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

$(document).ready(main);


#2

Here, you wrote

Whereas, you should be writing,

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

You wrote characterLeft and in other places you wrote charactersLeft.

Hope this helps! :slight_smile:


#3

I noticed this just after i posted this, thank you though!


#4

Good you did. You're welcome.

Have fun coding! :slight_smile:


#5

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