The dom hierarchy can be different in different browsers (sometimes we need a container node and sometimes we do not). This means you can’t rely on parentNode always being the same element. You may want to use a loop instead and look at the element class to make sure you find the element you are looking for.
In my case,
an element or a symbol within a symbol is tapped/clicked. A javascript is triggered and depending on which symbol instance that is the ‘holder’ of these elements and symbols, different things should happen.
What is the best way to solve something like this, covering e.g. IE browsers?
How would a loop like that be?
As it is now, it seems to work on OS X, iOS, Android, with the webkit and gecko based browsers…
It depends a bit on your setup, but the basic idea is that you iterate through parentNodes until you find the one you are looking for. You could either set a class on all symbols and look for that or have specific ids on the symbols you care about.
var parent = element;
while (parent != null) {
if (parent.id == 'mySymbolId') {
//do work here
console.log('found symbol ' + parent);
break;
}
parent = parent.parentNode;
}