jQuery.trim( str )
<!DOCTYPE html>
<html>
<head>
<title> jQuery trim() method</title>
<script src = "/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h4> This is an example of using trim() method </h4>
<p style = "color: blue;"> Click the following button to trim the string </p>
<button id = "btn"> Click me </button>
<script>
$(document).ready(function(){
$("#btn").click(function(){
var str = "\n\n Welcome to the bianchenghao6.com \n\n";
alert("The original string is: " + str);
str = jQuery.trim(str);
alert("The trimmed string is: " + str);
});
});
</script>
</body>
</html>
Click the following button to trim the string