specific word count (index of )
<script type="text/javascript"> var str="Hello world!" document.write(str.indexOf("Hello") + "<br />") document.write(str.indexOf("World") + "<br />") document.write(str.indexOf("world")) </script>
输出结果:
0,
-1,
6
转自:wusifan的博客