标签:while welcome alert dex index 获取 com world nbsp
indexOf方法可以传两个参数,第二个参数是传位置的参数,利用这点获取所有的位置。例如:
var str = "hello world,welcome!";
var arr = [];
var pos = str.indexOf("o");
while(pos>-1){
arr.push(pos);
pos = str.indexOf("o",pos+1);
}
alert(arr);
标签:while welcome alert dex index 获取 com world nbsp
原文地址:http://www.cnblogs.com/Ushadow/p/6273888.html