JS分割字符串,放入数组

mac2022-06-30  27

var InterestKeywordListString = $("#userInterestKeywordLabel").html();     var InterestKeywordListArr = [];     var t = '';     for (var i = 0; i < InterestKeywordListString.length; i++) {         var tmp = InterestKeywordListString.charAt(i);         if (tmp != '' && tmp != ',') {             t += tmp;             lastNum = true;         } else {         if (t != '' && t != ',') {                 InterestKeywordListArr.push(t);                 t = '';             }             lastNum = false;         }     }     if (t != '' && t != ',') {         InterestKeywordListArr.push(t);     }          for(var i=0;i<InterestKeywordListArr.length;i++){         alert( InterestKeywordListArr[i] );     }

 

 

据说看了不回帖的人,经常玩 DeBug  

 

转载于:https://www.cnblogs.com/caicainiao/archive/2011/07/02/2096275.html

最新回复(0)