String indexOf() : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

String indexOf()



/* first position in the string is 0! */
<html>
<body>

<script type="text/javascript">

var str="JavaScript is great!"
var pos=str.indexOf("great")
if (pos>=0){
    document.write("great found at position: ")
    document.write(pos + "<br>")
}else{
    document.write("great not found!")
}

</script>
</body>
</html>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» String