Use indexOf method the search a substring : indexOf : String JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » String » indexOf »

 

Use indexOf method the search a substring

















<html>
<head>
<title>Using the indexOf() method</title>
<script type="text/javascript" language="javascript">
<!-- //

var myString = "A ab abc abcd";
var mySubstring = "abc";
var foundAtPosition;
foundAtPosition = myString.indexOf(mySubstring,0);

document.write("<P>The string " + mySubstring + " was found at position " + foundAtPosition);
// -->
</script>
</head>
<body>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo String
» indexOf