indexof ie8不支持数组

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" id="spanFiled" />
</body>
<script type="text/javascript">

/* if(!Array.indexOf){
    Array.prototype.indexOf = function(obj){
    for(var i=0; i<this.length; i++){
      if(this[i]==obj){
        return i;
      }
    }
  return -1;
  }
}*/
// var aaa = $(":input").eq(0).attr("id");
var aaa = document.getElementsByTagName("input");
aaa[0].getAttribute("id");
var bbb = ["你好","大家好","请问"]
var ccc = aaa[0].getAttribute("id").split("F");
if(bbb.indexOf("大家好")>-1){
alert(1);
}
</script>
</html>

原文地址:https://www.cnblogs.com/Super-Zhen-/p/6211453.html