JavaScript not changing display type or color in IE

Posted by user445359 on Stack Overflow See other posts from Stack Overflow or by user445359
Published on 2011-11-24T01:10:53Z Indexed on 2011/11/24 1:50 UTC
Read the original article Hit count: 105

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about internet-explorer