JS分割字符串并放入数组的函数
更新时间:2011年07月04日 23:33:09 作者:
JS分割字符串并放入数组的函数,需要的朋友可以参考下。
复制代码 代码如下:
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中getBoundingClientRect的作用及兼容方案详解
这篇文章主要介绍了js中getBoundingClientRect的作用及兼容方案详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-02-02
关于BootStrap modal 在IOS9中不能弹出的解决方法(IOS 9 bootstrap modal ios
本文给大家介绍BootStrap modal 在IOS9中不能弹出的问题以及bootstrap datepicker 在bootstrap modal中不显示问题的解决方案,非常不错,需要的朋友参考下2016-12-12


最新评论