7/9 Remember to add $('.btn').addClass('disabled');


#1



I have looked at numerous answers for this problem but to no avail. I do not see any problems with it. Do you? Thanks is advance.

Error message: Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler


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

$(document).ready(main);


#2

@viv6102,

Have a close look at

$('.counter').text(charactersLeft


#3

Must've accidentally deleted it during typing! Thanks a bunch!


#4

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