代码编辑器:
x
1
<p id="demo">单击按钮从位置5开始查找“e”第一次出现的位置</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
function myFunction(){
5
var str="Hello world, welcome to the universe.";
6
var n=str.indexOf("e",5);
7
document.getElementById("demo").innerHTML=n;
8
}
9
</script>
10