Disable the button 2


#1


Disable the button 2

Oops, try again. Remember to disable the Post button after posting a new message. i already disable the button

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 @creat,

Please post a link to the exercise you're on so we can help you.


#3

https://www.codecademy.com/courses/web-beginner-en-hk5qh/0/8?content_from=make-an-interactive-website%3Ajquery-dom-manipulation


#4

@creat This is what the error message says:

Remember to disable the Post button after posting a new message

So look at your code and the output - how are you submitting a new comment, and do you have an event listener for that? If you do, are you disabling the button in that event listener?


#5

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