Posted in Javascript onJuly 04, 2011
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] ); }
JS分割字符串并放入数组的函数
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@