Unit 4 Lesson 7 Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler


#1

I don't see the mistake.

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

Hi @snullboy,

Could you please post a link to the exercise you're on?


#3

Uncaught SyntaxError: Unexpected identifier, right? A simple dot should do the trick.

Instead of :

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

try

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


#4

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