为什么在js编写的函数不用调用

<script type="text/javascript">

function getElementsByClassName (className) {
  var all = document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++) {
    if (all[e].className == className) {
      elements[elements.length] = all[e];
    break;
    }
  }
  return elements;
}

window.onload = function(){
  var watch = document.getElementById('watchmore');
  var op = document.getElementsByTagName('p').getElementsByClassName('none');
  watch.onlick = function(){
    if(watch.innerHTML == "显示"){
      for(var i=0; i<op.length; i++){
        op[i].style.display = "block";
        watch.innerHTML = "隐藏";
        }
      }
    else {
      for(var i=0; i<op.length; i++){
        op[i].style.diaplay = "none";
        watch.innerHTMl = "查看更多";
        }
      }
    }
  }

</script>

 

 

为什么当我点击那个按钮的时候,提示document.getElementsByTagName(...).getElementsByClassName is not a function

 

 

SMILET
浏览 447回答 3
3回答

UYOU

直接document.getElementsByClassName('none');这样用

大话西游666

显然是不对的
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript