实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>String Type Location Methods Example 2</title>
5
    <script type="text/javascript">
6
    
7
        var stringValue = "Lorem ipsum dolor sit amet, consectetur adipisicing elit";
8
        var positions = new Array();
9
        var pos = stringValue.indexOf("e");
10
        
11
        while(pos > -1){
12
            positions.push(pos);
13
            pos = stringValue.indexOf("e", pos + 1);
14
        }
15
            
16
        alert(positions);    //"3,24,32,35,52"
17
    </script>
18
</head>
19
<body>
20
21
</body>
22
</html>