Step 5: would var work instead of text?



In this code

var main = function() {

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

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

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

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

Thanks in advance for any help


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!