Lesson 5. Count characters - not workin


#1



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);


#2

Hi @jarkownik,

Check your selecter for .status-boxx on line 5 - it needs to have a dot (.) in front of status-box, since you're selecting a class, not a tag :slight_smile:


#3

Yes I had mistake there but it is from previous one and fixing it does not help at all, I tried it before.


#4

@jarkownik That's the only problem in your code I can find. Could you post it with that change made?

Also, a link to the exercise you're on and the error message you're getting would make it easier for us to help you.


#5

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);

Lesson

Error:

Oops, try again. Remember to update the '.counter' to show how many characters are left.


#6

@jarkownik On line 5, replace the dot (.) at the end of the line with a semi-colon (;), and your code should work :slight_smile:


#7

Worked!
Thank you!
:heart_eyes:


#8

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