What symbols can be removed by the jquery trim method?

青灯夜游
Release: 2021-11-15 16:58:45
Original
2190 people have browsed it

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.

What symbols can be removed by the jquery trim method?

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)
Copy after login
  • 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">
Copy after login
Copy after login
<script> $(function () { var str = " lots of spaces before and after "; $( "#original" ).html( "原始字符串: &#39;" + str + "&#39;" ); $( "#trimmed" ).html( "使用$.trim()&#39;后: &#39;" + $.trim(str) + "&#39;" ); }) </script>

What symbols can be removed by the jquery trim method?

Related tutorial recommendations: jQuery video tutorial

The above is the detailed content of What symbols can be removed by the jquery trim method?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template