How does one select DOM elements in javascript?
Like for example:
<div class=des>
<h1>Test</h1>
<div class=desleft>
<p>Lorem Ipsum.</p>
</div>
<div class=Right>
<button>Test</button>
</div>
</div>
Now how do i select h1
? This is just a part of a bigger Page, so cannot use getElementsByTagName()
, since others might get selected. Also since there might be other h1
's in the document later, i cannot attach the index(body's) to above.
Is there a simple way to select, say <h1>
tag which is under the classname of desleft
?
I cannot use jQuery or any other libraries.