Having Trouble With Lesson 8, "Disable Button 2"


#1

Hello. I am having trouble with lesson 8, "disable button 2" I am getting a msg stating "Oops remember to disable the post button after making a post"
Here is the code that I have written. I have looked all over the forums, and cannot seem to find what I am doing wrong.

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(charactersLeft == 140) {
    $('.btn').addClass('disabled');
    }
    else {
    $('.btn').removeClass('disabled');
    }
    });
    $('.btn').addClass('disabled');

    };

    Thanks for any help
    $(document).ready(main)


  • #2

    @mish181
    So according to the Oops-message you should extend your code
    with which you create a Post.....

    $('.btn').click(function() {
        //collect the TEXT into a VARIABLE =post=
        var post = $('.status-box').val();
         // writeout the contents of the =post= VARIABLE as new-line
         $('<li>').text(post).prependTo('.posts');
         // reset the TEXT collection environment
         $('.status-box').val('');
         $('.counter').text('140'); 
    });

    #3

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