In jquery, the trim() method can remove whitespace symbols at both ends of a string, including newlines, spaces, and tabs. The syntax is "$.trim(string)"; the parameter "string" specifies the need A string with whitespace characters removed from both ends.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, the trim() method can remove whitespace characters at both ends of a string.
$.trim() function removes all newline characters, spaces (including consecutive spaces) and tab characters at the beginning and end of the string. If whitespace characters are in the middle of the string, they are retained and not removed.
Syntax:
$.trim(string)
string: Required parameter, String type, specifies the string that needs to remove blank characters at both ends.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script src="js/jquery-1.10.2.min.js"></script> </head> <body> <pre id="original">