No change in the preview repeatedly saying uncaught error $(...).val().length is not a function


#1


uncaught type errror $(...).val().length() is not a funtion

var main=function() {
    $('.btn').click(function() {
    var post =  $('.status-box').val();
    $('<li>').text(post).prependTo('.post');
    $('.status-box').val('');
    $('.container').text("140");
    $('.btn').addClass('disabled');
    }); 
    $('.status-box').keyup(function() {
        var postLength = $(this).val().length();
        var charactersLeft = 140 - postLength;
        $('.counter').text(charactersLeft);
        if(charactersLeft<0)
        {
        $('.btn').addClass('disabled');
        }
            else if (charatersLeft==140)
         {
             $('.btn').addClass('disabled');
         }
         else
         {
             $('.btn').removeClass('disabled');
         }
    });
    $('.btn').addClass('disabled');
    
};
$(document).ready(main);


#2

@jay1543,
length is a so-called property
and NOT a Method/Function !!!!
Try it by using

var postLength = $(this).val().length;

PS.
Please delete your other post...


#3

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