I am capturing keydown
event for my document. This event can be fired from anywhere in the document. The document is made up of several divs
. I want to determine if the HTML element that fired keydown
event is descendant of particular div
. Lets say I have the documnet which looks like this:
<div class="div1">...</div>
<div class="div2">
<div>
<div>
<input type="text" id="txt1"/>
</div>
</div>
</div>
<div class="div3">...</div>
If txt1
fires keydown event I need to determine if it is descendant of div2
. txt1
could be immediate child or grand-child or so on. Please let me know how can we do it?