Whats wrong?


#1

Remember to reset the '.counter' to 140 after posting a message.

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);
    });
    };
    $(document).ready(main)

  • #2

    Hi Chris,

    You're missing a dot (.) in front of counter on line 6 :)
    The dot is necessary, because there are three main ways to select an element:

    $('#id') // with a #id
    $('.class') // with a .class
    $('tag') // with a tag name

    It's important to differentiate between the three, because you might have different elements with a similar .class or #id. Your code was looking for the HTML element <counter> :)