<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>实践题 - 选项卡</title>
</head>
<body>
<!-- HTML页面布局 -->
<span id='s1'>房产</span><span id='s2'>家居</span><span id='s3'>二手房</span>
<script type="text/javascript">
var span=document.getElementsByTagName('span');
for(var i=0;i<span.length;i++){
alert(span.indexOf(span[i]))}
</script>
</body>
</html>
明明能找到3个span对象,也能遍历,但是indexOf无效
你这个目测应该是span[i].innerHTML indexOf()检索字符串吧