The W3C team's head was kicked off until javascript1.8.1 supported the trim function (with trimleft and trimright). Unfortunately, only firefox3.5 supported it now. Since the blank spaces on both sides of the string are too common, all major types
The string class in Java has a trim () to remove space characters before and after a string. jquery also has the trim () method to remove strings before and after a character variable.However, there is no corresponding trim () method in JavaScript.
The string class in Java has a trim () to remove the space characters before and after the string, and the trim () method in jquery can delete the string before and after the character variable. But there is no corresponding trim () method in
About trim in fact, nothing to say, is to remove the first space, for modern browsers is simply a regular/^\s+|\s+$/can be done.JavaScript Regular expressions implement trim ()
The code is as follows
Copy Code
Trim has nothing to say about. It is nothing more than removing the first space. For modern browsers, it is just a simple regular expression/^ \ s + | \ s + $. It also supports Chinese spaces & nbsp; and so on. What \ s supports Chinese spaces? Yes.
In Java, the trim () function represents the removal of the front and back spaces of a string, but there is no trim () function in JavaScript, so you need to override this function if you want to use it. Specific as follows:function Trim (str) {
The people's brains were kicked by the donkey until javascript1.8.1 support the Trim function (and trimleft,trimright), but now only firefox3.5 support. Because it is too often used to remove whitespace on both sides of a string, each large class
Usually, when the form is validated, the text of the input box needs to be taken out of the string and trailing blanks.The current version of the browser is natively supported by the trim () method, and the previous version of JQ also implements
The W3C team's head was kicked off until javascript1.8.1 supported the trim function.
The W3C team's head was kicked off until javascript1.8.1 supported the trim function (with trimLeft and trimRight). Unfortunately, only firefox3.5 supported it now.
Because of the previous version of JavaScript 1.8.1, there is no built-in trim function, so JQuery has its own implementation. In different versions of jquery, the TRIM function is implemented differently.Read this article to master the use of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.