5. are .val() and .text() the same?


#1


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

I would just like to ask why are these two methods .text() and .val() not working after swaping. Are they doing the same job? It seems that yes. But when i swap them in this exercise, it doesn't work. Why?


var main = function(){
    $('.btn').click(function(){
        var post = $('.status-box').val();
        $('<li>').text(post).prependTo('.posts');
        $('.status-box').text('');
    });
    
    $('.status-box').keyup(function(){
        var postLength= $(this).val().length;
        var charactersLeft = 140 - postLength;
        $('.counter').val(charactersLeft);
    });
    
}

$(document).ready(main);


#2

@kalenz3,
With a google search
== discussions / opinions ==
jquery val() vs text() site:stackoverflow.com
for instance
http://stackoverflow.com/questions/807867/difference-between-val-and-text
and
http://stackoverflow.com/questions/8854288/val-vs-text-for-textarea