Modify the value of each textfield based on original value using jQuery

Can just use val() with a callback argument. It will loop over all elements for you:

$('input[type=text]').val(function( index, originalValue){
     return $.trim(originalValue);
});

val() API docs

Leave a Comment