<script>function repeat(str) {let h2 = document.getElementsByTagName('h2');console.log(h2[0].innerHTML.length);console.log(str);h2[0].className = ('body');h2[0].style.background = "red";h2[0].onmousemove = function () {alert('这里');}for (var i = 0; i < h2.length; i++) {let keyword = h2[i].innerHTML.charAt(i);for (var j = 0; j < h2[i].innerHTML.length; j++) {if (keyword === str) {console.log("敏感字" + str + "在" + i + "位置被发现<br>");}}}return console.log("没有该字");}repeat("感冒");}</script>
添加回答
举报
0/150
提交
取消