我在Codecademy做一个互动网站,我不能通过7/9禁用按钮1

I am on Codecademy Make an interactive website, I can't pass 7/9 "Disable the button 1

本文关键字:不能 按钮 Codecademy 网站 一个 我在      更新时间:2023-09-26

当我提交代码时,它一直告诉我:

确保你已经定义了所有的变量!

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(characterLeft == 140) {
$('.btn').addClass('disabled');
}
else { 
 $('.btn').removeClass('disabled');
}
});
$('.btn').addClass('disabled');
};
$(document).ready(main);
else if(characterLeft == 140) {

你的变量叫charactersLeft