Is there a way to get a reference to the container of a Javascript function?
To give an example:
<div>
<script>
var thisDiv = ???
doSomething(thisDiv);
</script>
</div>
It seems that the this
keyword only refers to the containing element when it is triggered by direct event such as onClick()
. Otherwise this
refers to the containing window
element. Is there any equivalent way to get the parent or containing element of a <script>
snippet ?