js / jq 去除两边空格或多余空格方法

-----------------------js-----------------------

function IgnoreSpaces(Str){
    var ResultStr = "";
    Temp=Str.split(" "); //双引号之间是个空格;
    for(i = 0; i < Temp.length; i++)
    ResultStr +=Temp[i];
    return ResultStr;
}

----------------------jq--------------------------

$.trim("    hello, how are you?    ");

 

posted @ 2016-11-22 00:15  Koidt  阅读(869)  评论(0)    收藏  举报