码迷,mamicode.com
首页 > 其他好文 > 详细

Indexof

时间:2016-08-16 00:15:26      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

注释:indexOf() 方法对大小写敏感!

注释:如果要检索的字符串值没有出现,则该方法返回 -1。

实例

在本例中,我们将在 "Hello world!" 字符串内进行不同的检索:

<script type="text/javascript">

var str="Hello world!"
document.write(str.indexOf("Hello") + "<br />")
document.write(str.indexOf("World") + "<br />")
document.write(str.indexOf("world"))

</script>

以上代码的输出:

0
-1
6

Indexof

标签:

原文地址:http://www.cnblogs.com/gyrgyr/p/5774630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!