Need help with exercise 5


#1


Keeps saying "Oops, try again. Remember to update the '.counter' to show how many characters are left." and I can't figure out why. Rewrote the code and still having issues.


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

Link to exercise: https://www.codecademy.com/en/courses/web-beginner-en-hk5qh/0/5?content_from=make-an-interactive-website%3Ajquery-dom-manipulation

counter is a class, so to select it you'll need to use .counter.


#3

thanks for noticing that for me.

Even after changing it to ('.counter'), i still get the same message..


#4

Sorry, I was focusing on the counter. You have the same mistake with .status-box.


#5

@stephmatt93
As what @albionsrefuge wrote...
the same goes for the ".status-box"

- - - - - - - - - - - - S t a t u s U p d at e - - - - - - - - - -

= = = = = = = D ocument O bject M odel = = = = =

                     2html
                       |
        |--------------+-----------|
      3head                      8body
        |                          |
  |-----|+----|                    |
  |     |     |                    |
4link 5link 6link                9div
                                   |
  |----------------|---------------+---|--------------|
  |                |                   |              |
10form           15div(.button-group 20ul         24script(2x)
   |                |  .pull-right)    (.posts)    25script
11div(.form-group)  |
   |                |
12textarea          |
    (.form-control  |
    .status-box)    |
                    |
         |----------+----|
       16p(.counter)   17a(.btn
         |               | .btn-primary)
        text            text
        node            node

#6

thank you for that! it works now.

You guys are awesome


#7

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