I have this line of code (where ‘e’ is a click event):
var type = $(e.currentTarget.parentNode)[0].classList[0];
which is producing this error in IE7 (using Companion.JS to report errors):
'0.classList.0' is null or not an object
I tried the following variations on my code, but get the same result:
var type = $(e.currentTarget).parent()[0].classList[0];
var type = $(e.currentTarget).parent()['0'].classList['0'];
This code works in the latest Chrome and Firefox browsers. Any idea what’s going on here?
First check the
.lengthof$(e.currentTarget.parentNode), you might have to add a condition for IE because thecurrentTargetis inconsistent with other browsers.Also, classList is not supported in IE.
Code with classList does not work in IE?
parse the
.attr('class')or[0].className