Hi everyone,
I am getting stuck with an onClick function. I test for matching ‘id’s in the html document and when I have a match I want to attach the onClick function. In firebug I can see the match in the if statement is fine, the onClick function is attached to the element and I can watch it stay there through to the end of debug session. But when I click on the element, I get no love.
[CODE]window.onload = function() {
var level2List, level1List, level1ID, level2ID, eltToClick, eltToHide, eltAttributes, i, j;
level1List = document.getElementsByClassName(“level_1_menu”);
level2List = document.getElementsByClassName(“level_2_menu”);
for (i = 0; i < level1List.length; i++) {
level1ID = level1List[i].id;
for (j = 0; j < level2List.length; j++) {
level2ID = level2List[j].id;
if (level1ID == level2ID) {
eltToClick = level1List[i];
eltToHide = level2List[j];
eltToClick.onClick = function () {
alert(“Click!”);
}
}
}
}
}
Any help is greatly appreciated. ?