<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>string对象 </title><script type="text/javascript"> var mystr="Hello World wow o!" var i; for(i=0,i<=mystr.length,i++){ i=mystr.indexOf("o",i); document.write(i);} </script></head><body></body></html>
1 回答
慕数据5775487
TA贡献76条经验 获得超19个赞
for(i=0;i<=mystr.length;i++)是分号,不是逗号吧!
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>string对象 </title> <script type="text/javascript"> var mystr="Hello World wow o!" var i; for(i=0;i<mystr.length;i++){ var a=mystr.indexOf("o",i); if(mystr[i]=="o"){ document.write(a+'<br>'); } } </script> </head> <body> </body> </html>
添加回答
举报
0/150
提交
取消