title: Hide and show a div using input value using JavaScript
body: <p>Someone help me with the below code I want to hide and show a div using input value using JavaScript.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
      
      &lt;head&gt;
      &lt;script&gt;
      function (){
        document.getElementById('ref3').value;
          if (value == 2) {
            document.getElementById('div').style.visibility = 'visible';
          } else {
            document.getElementById('div').style.visibility = 'hidden';  
          }
      }
      &lt;/script&gt;
      &lt;/head&gt;
      
      &lt;body&gt;
          &lt;form name="myform"&gt;
              &lt;div&gt;&lt;input type="text" id="ref3" value=""&gt;&lt;/div&gt;
              &lt;div id="div" style="visibility:hidden"&gt;
                  &lt;label&gt;Show me&lt;/label&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/body&gt;
      
      &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>