Step 5: would var work instead of text?

jquery

#1

In this code

var main = function() {

$('.btn').click(function() {
...
});

$('.status-box').keyup(function() {
var postLength = $(this).val().length;
var charactersLeft = 140 - postLength;
$('.counter').text(charactersLeft);
});
}

Would $('.counter').val(charactersLeft); work?

It seem no but i can't quite get why.

Thanks in advance for any help


#2

Hi Eleclipse,

val() is for text input - <input>, <textarea>, etc.
text() is for static stuff - think the text inside .counter :)

I hope this helps, please let me know if you've got any more questions!