Call $.trim the tool function called, can delete the left and right side of the string space, but the function can not delete the middle of the string, the call format is:
$.trim (str);
The parameter str indicates that you need to delete the left and right character strings.
<body> <div id= "Divtest" > <div class= "title" > <span class= "FL" > String manipulation function </sp an> <span class= "fr" > <input id= "btnshow" name= "btnshow" type= "button" value= "calculation"/ > </span> </div> <div class= "Content" > <input id= "txtname" nam E= "Txtname" type= "text"/> <div class= "Tip" ></div> </div> </div> <SC Ript type= "Text/javascript" > $(function () { $("#btnShow"). Bind ("click",function () { $(". Tip"). HTML (""); varstrtmp = "Content:"; varStrold = $ ("#txtName"). Val (); varStrnew =$.trim (Strold); Strtmp+=Strold; Strtmp+ = "<br/><br> remove space before the length:"strtmp+=strold.length; Strtmp+ = "<br/><br> the length after the space is removed:"strtmp+=strnew.length; $(". Tip"). Show (). append (strtmp); }); }); </script></body>
Content: DFDDF
Length before removal of space: 9
Length after removal of space: 5
JQuery Tool class functions-string manipulation functions