Interactive Website: Status Update. disable the button


#1

This is my code:

var main = function() {
};
('.btn').click(function() { var post = (’.statusbox’).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);

This is the error that i get when i try to submit it:
Oops, try again.
Remember to add the line $(’.btn’).addClass(‘disabled’); outside your keyup event handler

Can someone help me with this problem?


#2

The problem should be corrected when you close your main function at the end and not at the beginning of the script. Close it just before the line $(document).ready(main);


#3

one thing I observed instead of btn, .btn should be use