title: javascript [No Jquery] Check if an element is inside a div or not
body: <p>I want to check if the element is not directly inside a <code>div</code>.</p>
  
  <p>For example Consider the follwing markup-</p>
  
  <p>If I place a <code>div</code> inside another <code>div</code>.</p>
  
  <p>Then I could use this code-</p>
  
  <pre><code>if(document.getElementById('innerDiv').parentElement.id == 'outerDiv') )
  </code></pre>
  
  <p>where innerdiv is inside the outerdiv.</p>
  
  <p>But what if I place four <code>div's</code> inside one another then how can i check that any div is inside the given div.</p>
  
  <p>there may be a better option than using this code</p>
  
  <pre><code>innerelem.parentnode.parentnode.parentnode.parentnode
  </code></pre>
  
  <p>I hope i was able to explain what i want to do????</p>