Interactive Website: Status Update Count characters left


#1



Interactive Website: Status Update
Count characters left


Oops, try again. Remember to update the '.counter' to show how many characters are left.
What's wrong with this code?

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


$(document).ready(main);


#2

It looks like you have put your keyup function inside of your click function. Don't worry about giving yourself a bit of whitespace so you can more easily see what you are doing.

// this is the beginning of your main function
var main = function() {

  // this is the beginning of your click function
  $('.btn').click(function() {
    var post = $('.status-box').val();
    $('<li>').text(post).prependTo('.posts');
  // you are missing code here
  // you haven't ended this click function

  // this is the beginning your keyup function
   $('.status-box').keyup(function() {
    var postLength = $(this).val().length;
    var charactersLeft = 140 - postLength;
    $('.counter').text(charactersLeft);
  }); // end of keyup function

  }  // a stray } -- ??

}  // end of main function

#3

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