Count Characters Left


#1

Hi I have been using this website to learn for few months now and i have a problem

I need help in clearing the error how to update the counter

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

The error has been put and i cannot figure out the problem

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


#2

Hi Ashwin,

That selects the HTML <status-box> element, which doesn't exist. You need to change it to $('.status-box') (with a dot (.)), so it selects the element(s) with the class="status-box" attribute instead :slightly_smiling:


#3

Thanks for the help. I am greatful


#4

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