7.Disabled the button 1


#1

i cant figure out where is the problem,please help."Oops, try again. Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler"
var main = function() {

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

  • ').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 (characterLeft == 140) {
    $('.btn').addClass('disabled');
    }

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

    });

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

    $(document).ready(main);


  • #2

    @etthegeek,
    You are forgetting 1 closing-curly-bracket-}
    which would close the FUNCTION-BODY of the =main= function....


    #3

    OMG...Thanks a lot!!:slightly_smiling:


    #4

    A post was split to a new topic: Can't figure out what's wrong on #7


    #5

    3 posts were split to a new topic: Need help on #7 - "Remember to add the line $('.btn').addClass('disabled')" error


    #8