What is wrong with my Disable the button?


#1

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

    $('btn').addClass('disabled');
    }
    $(document).ready(main);


  • #2

    @codequeen2016,

    Have a close look at jQuery-Selector

    $('btn')


    #3

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