<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>javascript统计</title>
</head>
<body>
<input type="submit" name="dd" value="点击" οnclick="show()">
<script>
function show(){
var a="123456789123456789";
var b="123";
// alert(a);
var count=0;
// alert(count);
var i=0;
for(i=0;i<=a.length;i++){
if(a.indexOf(b)==i){
a=a.substring(i+1,a.length);
count++;
}
}
alert(count);
}
</script>
</body>
</html>