问答详情
源自:7-10 提取字符串substring()

为什么加了第二句就出不来结果呢

谢谢帮助我的同学们!

提问者:夜蝶翱翔 2016-12-28 23:02

个回答

  • qq_灰色头像_17
    2017-08-22 11:17:53

    俩问题,首先少个),还有就是如果你想找空格符,应该是“ ”,而不是“”,用我下面的能行

    <!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"),mystr.length) + "<br />");

    document.write(mystr.substring(1,mystr.indexOf(" ",0)));

    </script>

    </head>

    <body>

    </body>

    </html>


  • 空白185
    2017-01-08 18:28:27

    document.write(mystr.substring(1,mystr.indexOf("",0));

    这段结尾缺了‘)’,导致结果输不出来

  • qq_九天揽月
    2016-12-28 23:32:06

    输出第二行少了“)”

  • qq_九天揽月
    2016-12-28 23:31:04

    <!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"),mystr.length) + "<br />");

    document.write(mystr.substring(1,mystr.indexOf("",0)));

    </script>

    </head>

    <body>

    </body>

    </html>