JS分割字符串并放入数组的函数

时间:2011-07-04    点击:108   
复制代码 代码如下:

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]
);
}
JavaScript 判断日期格式是否正确的实现代码
Javascript计算时间差的函数分享
ajax 同步请求和异步请求的差异分析
Extjs EditorGridPanel中ComboBox列的显示问题
Extjs gridpanel 出现横向滚动条问题的解决方法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved