Ex 8 Disable button 2 help!


#1

Hi, can't seem to get it to work and not sure where I have gone wrong.Can anyone shed any light on my mistakes?. Keep getting the error message "Oops, try again. Remember to disable the Post button after posting a new message."
Thanks

var main = function() {
$('.btn').click(function() {
var post = $('.status-box').val();
$('

  • ').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);

    `


  • #2

    Hello @summerscalestj,

    Can you add a link to the exercise that you are having trouble with, and I will try my best to correct your errors :wink: !


    #3

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


    #4

    Hey @summerscalestj,

    If you notice closely, inside of your $(".btn").click(function()), you have forgotten to close the quote for $(".btn").addClass("disabled");. Fix this and you will be good to go.


    #5

    Thank you! Couldn't see the wood for the trees!


    #6

    No worries @summerscalestj, if you feel my answer was satisfactory, please put it down as the solution so that others know this post is closed. Keep coding hard :laughing:!


    #7

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