JavaScript not changing display type or color in IE
- by user445359
I am trying to switch a series of blocks between "none" and "block" based on the OnMouseOver property and to change the title of the selected list to yellow at the same time. The JavaScript code I have for this is:
function switchCat(cat) {
var uls = document.getElementsByClassName('lower-ul');
var titles = document.getElementsByClassName('lower-cat-title');
for (var i=0;i<uls.length;i++) {
uls[i].style.display = 'none';
titles[i].style.color = 'white';
}
if (cat != -1) {
var wanted = document.getElementById('lower-cat-'+cat);
var wantedTitle = document.getElementById('lower-cat-title-'+cat);
wanted.style.display = 'block';
wantedTitle.style.color = 'yellow';
}
}
It works with Chrome, Opera, and Firefox, however, it does not work with IE. When I test it in IE I get the error "Object doesn't support this property or method." Does anyone know what I am doing wrong?