为什么显示不了,各位大神
瞧一瞧,看一看
2016-12-01
你的第二个mystr写错了,第一个少了个括号,下面是正确的
<!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!"
document.write(mystr.substring(mystr.indexOf("W"))+"<br>");
document.write(
mystr.substring(
0,mystr.indexOf(
"d")));
</script>
</head>
<body>
</body>
</html>
<!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!" document.write(mystr.substring(mystr.indexOf("W"))+ "<br />"); document.write(mystr.substring(0,mystr.indexOf(" "))); </script> </head> <body> </body> </html>
这样是可以输出正确结果的。已测试
举报