Need help on exercise 5 - tells me to remember to update the '.counter' to show the characters left


#1

I'm having the same problem. Any ideas?

var main = function(){

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

  • ').text(post).prependTo('.posts');
    $('.status-box').val('');
    });

    $('.status-box').keyup(function() {
    var postLength = $(this).val().length;
    var charactersLeft = 140 - postLength;
    $('.counter').text(charactersLeft);
    });
    $(document).ready(main);
    }


  • #2

    @julienk403,
    Change

    into

    });
    };
    $(document).ready(main);

    #3

    Thanks for taking time to reply but I still get the same error message: Oops, try again.
    Remember to update the '.counter' to show how many characters are left.


    #4

    @julienk403,

    Please present the code you are using now...
    and do use the proper formatting ...


    #5

    Here it is:

    var main = function(){

    $('.btn').click(function() {   
        var post = $('.status-box').val();  
        $('<li>').text(post).prependTo('.posts');  
        $('.status-box').val('');  
    });  
    
    $('.status-box').keyup(function() { 
        var postLength = $(this).val().length;  
        var charactersLeft = (140 - postLength);  
        $('.counter').text(charactersLeft);  
    });

    });
    };
    $(document).ready(main);

    Over to the right, under the box, is this error message: SyntaxError: missing ; before statement

    Thanks again for looking at this.


    #6

    var main = function(){

    $('.btn').click(function() {   
        var post = $('.status-box').val();  
        $('<li>').text(post).prependTo('.posts');  
        $('.status-box').val('');  
    });  
    
    $('.status-box').keyup(function() { 
        var postLength = $(this).val().length;  
        var charactersLeft = (140 - postLength);  
        $('.counter').text(charactersLeft);  
    });
    };

    $(document).ready(main);

    This finally worked! Thanks for your help.


    #7