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


#1



After writing this it comes up with "Uncaught SyntaxError: Unexpected string" to the right of the screen and then error message "Oops, try again. Remember to update the '.counter' to show how many characters are left."

Any help appreciated!

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

@mabrownny,

Have a close look at

$'.status-box')

and as you want to reinitialize the status-box to an =empty= Value
use val("") instead of your val(" ")


#3

Ah cheers, works fine now


#4

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