title: Get First Next element with classname Plain Javascript
body: <p>I am trying to Get First Child with classname Plain Javascript.</p>
  
  <p>I am trying to write my own form validation and  trying the error message i appended and remove it. As well as dont append if error message is already there.</p>
  
  <p>If you help me with just the first part getting child with class name that whould be great.</p>
  
  <pre><code>    function display_error(selector, message) {
      selector.insertAdjacentHTML('afterend', "&lt;h1 class='js-error' &gt;" + message + "&lt;/h1&gt;");
  }
  
  function validateForm() {
      // Validate Name Field
      // Check if name has les than 3
      var elem = document.getElementById("name")
      if (elem.value.length &lt; 3) {
          display_error(elem, "Less than 3")
          return false;
      } else {
          // here is the error
          error_label = elem.querySelector('.js-error');
          error_label.textContent = "more than 3"
  
          }
  
  }
  </code></pre>
  
  <p>here is a fiddle
  <a href="https://jsfiddle.net/efh941cc/3/" rel="nofollow noreferrer">https://jsfiddle.net/efh941cc/3/</a></p>