jQuery find and replace with arrays

后端 未结 3 2143

I need to search an input\'s value for all street abbreviations and replace with appropriate suffix. This is what I have so far:

jQuery(\'#colCenterAddress\'         


        
3条回答
  •  一整个雨季
    2020-12-19 07:12

    var valArray = val.split(" ");
    
    for(x = 0; x < valArray.length; x++){
        for(y = 0; y < r.length; y ++){
            if (valArray[x] == f[y]){
                valArray[x] = r[y];
            } 
         }
    }
    return valArray
    

    You could always turn the array back into a string for the return if you like.

    Demo: http://jsfiddle.net/vRTNt/12/

提交回复
热议问题