JavaScript 字符串 indexOf函数


JavaScript 字符串 indexOf函数

<html>
   <head>
      <title>JavaScript String indexOf() Method</title>
   </head>

   <body>

      <script type = "text/javascript">
         var str1 = new String( "This is string one" );
         var index = str1.indexOf( "string" );
         document.write("indexOf found String :" + index );

         document.write("<br />");
         var index = str1.indexOf( "one" );
         document.write("indexOf found String :" + index );
      </script>

   </body>
</html>