G
GRotfl
Hi!
This question might be easy, but I am not even sure how to find the answer
on the Internet... I would appreciate some help.
I have this scenario:
....
<div>
<script type="text/javascript" src="test.js" /></script>
</div>
....
I would like the code in test.js to manipulate the node that it is called
from (for instance, set its background color to red).
Caveats:
- I can't use getElementById or similar because I don't control anything but
JS code (in other words, the code could be included from anywhere)
- test.js could be included in many places on the same page - each js should
manipulate only its parent and not parents of other JS includes.
So, I would need sth. like this:
var el=getThisNode.parentNode(); // not working of course
As said, I would appreciate some help, I'm really stuck here. Even "it can't
be done" would help, though I'm hoping of a different answer.
Kind regards!
This question might be easy, but I am not even sure how to find the answer
on the Internet... I would appreciate some help.
I have this scenario:
....
<div>
<script type="text/javascript" src="test.js" /></script>
</div>
....
I would like the code in test.js to manipulate the node that it is called
from (for instance, set its background color to red).
Caveats:
- I can't use getElementById or similar because I don't control anything but
JS code (in other words, the code could be included from anywhere)
- test.js could be included in many places on the same page - each js should
manipulate only its parent and not parents of other JS includes.
So, I would need sth. like this:
var el=getThisNode.parentNode(); // not working of course
As said, I would appreciate some help, I'm really stuck here. Even "it can't
be done" would help, though I'm hoping of a different answer.
Kind regards!