JS getElementsByClassName(ClassName)不工作:什么都没发生

Jam*_*mie -1 html javascript

代码:

(HTML)

<html>
  <head>
    <title>Float Image Gallery</title>
  </head>
  <body>
    <button onclick="showAllGalleries();">Show gallery</button>
    <div id="myGallery" class="gallery">
      <div class="gallery-close">
        <img src="http://bit.do/closeicon" onclick="showAds" />
      </div>
    </div>
   </body>
</html>

<style>
.gallery {
  display:none;
  width:100%;
  height:100%;
  left:0;
  bottom:0;
  top:auto;
  right:auto;
  position:fixed;
  background-color:#cccccc;
  opacity:50%;
}

.gallery-close {
  width:auto;
  height:auto;
  margin-top:4px;
  margin-left:4px;
}
<style>

<script>    
function showMyGallery(){
    document.getElementById('myGallery').style.display='inline';
}

function showAllGalleries(){
  var adsArray = document.getElementsByClassName("gallery");
  for (int i; i<adsArray.length; i++){
    adsArray[i].style.display='inline';
  }
}

function hideMyGallery(){
  document.getElementById('myGallery').style.display='inline';
}
</script>
Run Code Online (Sandbox Code Playgroud)

但是,showAllGalleries()似乎不起作用.
我的Javascript代码有什么问题?
尽量避免使用除Javascript之外的jQuery /语言建议答案.
非常感谢你的帮助.

Ami*_*oki 5

做这个:

for (var i = 0; i<adsArray.length; i++){
    adsArray[i].style.display='inline';
  }
Run Code Online (Sandbox Code Playgroud)

你没有int,string,float和其他数据类型,你在其他语言中都有.在javascript中你只有var