07搜索字符串.htm

来自「介绍了javascript的常用的函数」· HTM 代码 · 共 21 行

HTM
21
字号
<html>
<head>
<title>搜索字符串</title>
</head>
<body>
<script language="javascript">
<!--
	str = "JavaScript";
	ch = "S";
	index = str.indexOf(ch);
	
	document.write("str=" + str + "<br>");
	if (index != -1){
		document.write( ch + "的位置是:" + index);
	}else{
		document.write("没有找到你要搜索的字符串!");
	}
//-->
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?