title: Parent or ParentNode / Class Selector
body: <p>Class selector is not working and how do I always get the class that I apply the function in particular and not the first, because the items have the same class if the selector by class work it will take the first class and not in the element I'm applying.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;li class="space_form"&gt;
      &lt;label&gt;
          Nome*
          &lt;input type="text" class="no-empty" name="Nome" value="Nome" onFocus="formEmptyLeft(this);clearText(this)" onBlur="formEmptyLeft(this);clearText(this)" /&gt;
          &lt;div class="campo_vazio-left"&gt;*Preenchimento do campo obrigatório&lt;/div&gt;                                                                                     
      &lt;/label&gt;
  &lt;/li&gt;
  
  &lt;li class="fright"&gt;
      &lt;label&gt;
          Sobrenome*
          &lt;input type="text" class="no-empty" name="Sobrenome" value="Sobrenome" onFocus="formEmptyRight(this);clearText(this)" onBlur="formEmptyRight(this);clearText(this)" /&gt;
          &lt;div class="campo_vazio-right"&gt;*Preenchimento do campo obrigatório&lt;/div&gt;                                                                                                                                    
      &lt;/label&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function formEmptyLeft()
  {
      var input = document.getElementByClass('no-empty');
  
      if(input.value.length == 0)
      {
          document.getElementByClass('campo_vazio-left').style.display = 'block'; 
          document.getElementByClass('no-empty').classList.add('form_invalido');              
      }
      else {
          document.getElementByClass('campo_vazio-left').style.display = 'none'; 
          document.getElementByClass('no-empty').classList.remove('form_invalido');                   
      }       
  }   
  
  function formEmptyRight()
  {
      var input = document.getElementByClass('no-empty');
  
      if(input.value.length == 0)
      {
          document.getElementByClass('campo_vazio-right').style.display = 'block'; 
          document.getElementByClass('no-empty').classList.add('form_invalido');              
      }
      else {
          document.getElementByClass('campo_vazio-right').style.display = 'none'; 
          document.getElementByClass('no-empty').classList.remove('form_invalido');                   
      }       
  }   
  </code></pre>