jQuery: Trimming strings





The jQuery Code START
    
    <script type="text/javascript" src="./jquery-1.5.1.js"></script>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
  
    <script type="text/javascript">
      $(document).ready(function() {
         var myText = "   This is the text.     ";
         $("#target").text("Original: '" + myText + "'");
    
         
         var myText2 = jQuery.trim(myText);
         $("#target2").text("Trimmed: '" + myText2 + "'");
      });

      
    </script>
    
    <style type="text/CSS">
        <!--
        .code { color: red; }
        .back { background-color: yellow; }
        -->
   </style>
  </head>

  <body>
    <h1>jQuery: Trimming strings</h1>
    <div id="target"></div>
    <div id="target2"></div>
    <form>
      <button>Trim text</button>
    </form>