<html> <body> <script type="text/javascript"> //1. trim()函数,去除前后空格 var str = " Hello" var str_trim = str.trim(); if(str_trim == 'Hello'){ alert("trim:"+str_trim); } </script> </body> </html>