为什么会重复出现
<script type="text/javascript">
var mystr="Hello World!"
var pos = 0;
for (var i = 0; i < mystr.length-1; i++) {
pos = mystr.indexOf('o', pos);
document.write("'o'出现第" + (i + 1) + "次的位置是" + pos+'<br>');
pos++;
}
</script>
<script type="text/javascript">
var mystr="Hello World!"
var pos = 0;
for (var i = 0; i < mystr.length-1; i++) {
pos = mystr.indexOf('o', pos);
document.write("'o'出现第" + (i + 1) + "次的位置是" + pos+'<br>');
pos++;
}
</script>
2016-01-09
举报