Two way to trim?

Two way to trim?
0
$('#mygreatform').submit(function(){
      $(this).find('input:text').each(function(){
            $(this).val($.trim($(this).val())); // vs $(this).val().trim();
      });
});

Someone can explain what is do that both trim first inside and second not?

Thanks

$.trim is a jQuery method

.trim is standard JavaScript function

They both do the same thing. If you want to use the jQuery version you would write:

$.trim($(this.val())