Is it possible to get HTML element from which function is called in JavaScript?
For example I have this in my HTML:
<script type="text/javascript">
function myFunction() {
var myContainer = getElementFromWhichFunctionIsCalled(); // Possible?
(myContainer.id == 'my-container'); // TRUE
}
</script>
<div id="my-container">
<script type="text/javascript">myFunction();</script>
</div>
Thank you.
myFunction(this), which would explicitly pass in the the DOM<script>objectthiswould be the global context (window), not the<script>DOM node.