C
Casper Feldmann
Hello,
I am trying to access a certain id, but I don't know exactly how.
In my HTML I have the following.
....
<div id="abc123">
<input type="button" id="xyz789" />
</div>
....
Now I catch all the clicks with JS:
....
document.onclick = function(e) {
if (e.target.id == 'xyz789') {
// do something to 'parent' div so 'abc123'
...
}
}
....
This is my problem: How do I access the id name of the div containing
the target that was clicked?
I tried using the .parent.id properties, but that did not work. I tried
googleing, but I couldn't find anything relevant.
Can anyone give me a tip?
Thanks
C.
I am trying to access a certain id, but I don't know exactly how.
In my HTML I have the following.
....
<div id="abc123">
<input type="button" id="xyz789" />
</div>
....
Now I catch all the clicks with JS:
....
document.onclick = function(e) {
if (e.target.id == 'xyz789') {
// do something to 'parent' div so 'abc123'
...
}
}
....
This is my problem: How do I access the id name of the div containing
the target that was clicked?
I tried using the .parent.id properties, but that did not work. I tried
googleing, but I couldn't find anything relevant.
Can anyone give me a tip?
Thanks
C.