8th week blog 1

Posted husuiblogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了8th week blog 1相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
<head>
<title>查找</title>
<meta charset="utf-8">
</head>
<body>

<p>吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮</p>
<button onclick="find()">点击查看"葡萄"这个词出现的次数</button>

<p id="demo"></p>

<script>
function find(){


var str="吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮"
var y="葡萄";
var count=0;
var index=0;
for(z=0;z<=str.length;z++)
{
if(str.indexOf(y,index)!=-1)
{
index=str.indexOf(y,index)+y.length;
count=count+1;
}
}
document.getElementById("demo").innerHTML =count;
}
</script>

</body>
</html>

























以上是关于8th week blog 1的主要内容,如果未能解决你的问题,请参考以下文章

8th week blog

8th week blog 1

8th Week 2

February 22nd, 2018 Week 8th Thursday

May 8th 2017 Week 19th Monday

October 8th 2016 Week 41st Saturday