Disable Button 1 problem with code - Please help


#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);

    It seems that my code is correct, but it gives me the unexpected token ILLEGAL and the Oops, try again don't have the ('.btn') code under the Keyup function.


  • #2

    at the end of your code, after the $('.btn').addClass('disabled'); you're missing an extra };


    #4

    Hi @methodslayer68068,

    You need to remove the parenthesis (()) after else in your else statement towards the end.

    Next time you need help, please create a new topic rather than using someone else's.
    Thanks!


    #5

    Thanks for the help!


    #6

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