<script type="text/javascript">
var myString='abcadaefaaghai';
var position=0;
var count=0;
while(position!=-1){
position=myString.indexOf('a',position);
if(position!=-1){
count++;
position++;
}
}
alert(count);
</script>
indexOf()练习,查找某个字符出现的次数
最新推荐文章于 2022-04-17 16:24:32 发布