관리 메뉴

nalaolla

indexOf 본문

javascript/fundamental

indexOf

날아올라↗↗ 2016. 1. 7. 13:40
728x90
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Insert title here</title>
  6. <script type="text/javascript">
  7.     window.onload = function() {
  8.         var testValue = "This is the Cookbook's test string";
  9.         var subsValue = "Cookbook";
  10.  
  11.         var iValue = testValue.indexOf(subsValue); // returns value of 12, index of substring
  12.  
  13.         if (iValue != -1)
  14.             alert(iValue);
  15.     }
  16. </script>
  17. </head>
  18. <body>
  19.  
  20. </body>
  21. </html>


728x90

'javascript > fundamental' 카테고리의 다른 글

prompt  (0) 2016.01.07
type  (0) 2016.01.07
onload  (0) 2016.01.07