How do i trim in javascript or jQuery?
how do i trim using this
$('#type_of_station').text()
开发者_如何转开发
the result is
>>> $('#type_of_station').text()
"pizza delivery system "
As you can see there is a space after the last word
jQuery:
str = jQuery.trim(str);
JavaScript:
str = str.replace(/^\s*/, "").replace(/\s*$/, "");
Use the JQuery.trim() function.
精彩评论