title: replace class value in javascript
body: <p>I'm newer to Javascript, so sorry if I'm taking the wrong approach.</p>
  
  <p>I am looking to identify an element on a page by Class Name, hide it, and replace it with the text "Loading..."</p>
  
  <p>Here's what I have so far, which does successfully blank the page, however, my replacement message doesn't show. </p>
  
  <pre><code>&lt;style&gt;
  .loading{
  display: block;
  }
  &lt;/style&gt;
  &lt;script&gt;
  
  if (checkRequiredFields(document.forms[0]) &amp;&amp; document.InfoForm.FUDF9.value=="Y1")
  {
  var elems = document.getElementsByClassName("name");
  
  for (i = 0; i &lt; elems.length; i++) {
      elems[i].style.display = "none";}
  }
  
  &lt;/script&gt;
  &lt;div id = "loading"&gt;&lt;/div&gt;
  &lt;script&gt;
  var Message1 = "Loading...";
  if (checkRequiredFields(document.forms[0]) &amp;&amp; document.InfoForm.FUDF9.value=='Y1'){
  
  document.getElementByClassName("loading").innerHTML = Message1;}
  &lt;/script&gt;
  </code></pre>
  
  <p>It is a class name that a lot of elements on the page have, I've tried going to a narrower class name but that doesn't seem to hide the smaller individual elements. Any help would be appreciated.</p>
  
  <p>EDIT: Okay, I reworked everything so it's all operating off an ID. Still confused about why it will blank the page but not show my message.</p>
  
  <pre><code>&lt;style&gt;
  #loading{
  display: block;
  }
  &lt;/style&gt;
  &lt;div id = "loading"&gt;&lt;/div&gt;
  &lt;script&gt;
  
  if (checkRequiredFields(document.forms[0]) &amp;&amp; document.InfoForm.FUDF9.value=="Y1")
  {
  var elems = document.getElementsByClassName("name");
  
  for (i = 0; i &lt; elems.length; i++) {
      elems[i].style.display = "none";}
  }
  
  var quickPledgeMessage1 = "Loading...";
  if (checkRequiredFields(document.forms[0]) &amp;&amp; document.InfoForm.FUDF9.value=='Y1'){
  
  document.getElementById("loading").innerHTML = quickPledgeMessage1;}
  &lt;/script&gt;
  </code></pre>