jquery去除字符串首尾空格的方法:$.trim()
1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <script src = "http://libs.useso.com/js/jquery/1.8.3/jquery.min.js"></script> 9 <script> 10 var a=" x xx "; 11 var a = $.trim(a); 12 console.log(a) 13 </script> 14 </body> 15 </html>
坚持下去就能成功