js中indexof()简单使用
2024-10-16 12:35:10
indexOf()方法返回某个指定的字符串值在字符串中首次出现的位置。
stringObject.indexOf(searchvalue,fromindex);
indexOf()方法对大小写敏感
如果要检索的字符串值没有出现,则返回-1
<script>
var str="11Hello world!";
document.write(str.indexOf("Hello")+"<br />");
document.write(str.indexOf("Hello",3)+"<br />");
document.write(str.indexOf("World")+"<br />");
document.write(str.indexOf("world")+"<br />");
</script>
w3c官方文档http://www.w3school.com.cn/jsref/jsref_indexOf.asp
最新文章
- 年度巨献-WPF项目开发过程中WPF小知识点汇总(原创+摘抄)
- CSharpGL(1)从最简单的例子开始使用CSharpGL
- cosbench 异常 FreeMarker template error: The following has evaluated to null or missing
- 【译】Activitys, Threads和 内存泄露
- c coding style之学习篇
- 在windows命令行窗口下执行:查看所有的端口占用情况
- 20170510 mysql导入导出csv
- 计蒜客NOIP模拟赛(2) D1T1邻家男孩
- 编写程序,将来自文件中的行保存在一个vector<;string>;,然后使用一个istringstream 从vector中读取数据,每次读一个单词
- 五子棋棋盘布局 table和ul哪个好
- linux 6.5上创建新用户后,不能登陆?
- C#异步编程の----Threadpool( 线程池)
- Stateful Kubernetes Applications Made Easier: PSO and FlashBlade
- ReactCSSTransitionGroup
- 线特征---LineMatching原理(四)
- BugkuCTF ---游戏过关 writeup
- WinForm多线程实现HTTP网络检测工具
- python基础之字符串格式化
- [Android开发那点破事]解决android.os.NetworkOnMainThreadException
- #leetcode刷题之路47-全排列 II