getElementById works only in Firefox : No much to say, my script works fine in Firefox but its not in Chrome or IE or Opera

    var ids = ['id1','id2'];
    function myfunction() {
        for (var i = 0; i < ids.length; i++) {    
            var x = document.getElementById(ids[i]);
            if (x.style.display === "none") {
                x.style.display = "revert";
            } else {
                x.style.display = "none";
            }
        }
    }