jQuery去空格 <input id="txtUserName" name="txtUserName" value=""/> 給input輸入的值去空格:$.trim($('#txtUserName').val()) 註:隻能去掉左右兩邊空格,中間的空格去不掉。 摘自 徐越的專欄