我找不到問題。這是說:Codecademy - 互動網站:禁用按鈕2
糟糕,再試一次。請記住,在發佈新消息後禁用發佈按鈕
更新:事實證明Codecademy上有一個小錯誤,我重新提交了代碼並且它工作正常。
var main = function() {
$('.btn').click(function() {
var post = $('.status-box').val();
$('<li>').text(post).prependTo('.posts');
$('.status-box').val('');
$('.counter').text('140');
$('.btn').addClass('disabled');
});
$('.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);
}
'$ addClass(' 禁用 ')丙'的'(' 殘疾人',真正的')。 btn'點擊處理程序 – Tushar
您能否提供上述練習的codecademy鏈接? – WisdmLabs
當然。 https://www.codecademy.com/courses/web-beginner-en-hk5qh/0/8?content_from=make-an-interactive-website%3Ajquery-dom-manipulation – user5220317