title: How to Check if Div exists on Current Page
body: <p>I want to check if div exists on current page. I tried below condition, but it always goes through <code>div.value</code> even I check if <code>div</code> is <code>undefined</code> before going into <code>div.value</code>. </p>
  
  <p>How exactly can I check whether or not div exists on current page? </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-js lang-js prettyprint-override"><code>var div = document.getElementById("id");
  var id = div !== "undefined" ? div.value : null;</code></pre>
  </div>
  </div>
  </p>