jquery trim spaces - jQuery $.trim method

In this tutorial, I will explain how to removes the two whitespaces at the start and at the end of the string.
Removes the two whitespaces at the start and at the end of the string.
<html>
<title>jquery trim spaces</title>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
  $(document).ready(function(){
    
    $("span").click(function () {
      var str = "     jquery trim spaces     ";
      str1 = jQuery.trim(str);
      alert(str1);
    str2 = $.trim(str);//using the jQuery $.trim method
      alert(str2);
     });
  });
  </script>
</head>
<body>
  <span>jquery trim spaces</span>
</body>
</html>


I hope this tutorial will help you to remove whitespaces at the start and at the end of the string.