Trouble determining onclick's target
- by pwseo
I've tried and tried... and I can't seem to make this work in IE (tested version 6)
Can anybody help me? IE complains about an error but refuses to tell which error it is...
var a = document.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
if (a[i].getAttribute("class") == "info-link") {
a[i].onclick = function(e) {
e = e || window.event;
var target = e.srcElement || e.target;
var info = target.parentNode.getElementsByTagName("div")[0];
if (info.style.display == "none" || info.style.display == "") {
info.style.display = "block";
} else {
info.style.display = "none";
}
return false;
}
}
}
<div class="auxdata">
<a href="#" class="info-link">Esta questão possuí dados anexos. Clique para ver.</a>
<div style="display: none;" class="info-inner">
<!-- variable stuff here -->
</div>
</div>