Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:53:03+00:00 2026-05-27T01:53:03+00:00

I am trying to switch a series of blocks between none and block based

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:53:04+00:00Added an answer on May 27, 2026 at 1:53 am

    IE unfortunately does not support document.getElementsByClassName.

    Add your own support

    However, you can add support to this. You can create your own function, such as the following:

    document.getElementsByClassName = function(class_name) {
        var docList = this.all || this.getElementsByTagName('*');
        var matchArray = new Array();
        var re = new RegExp("(?:^|\\s)"+class_name+"(?:\\s|$)");
        for (var i = 0; i < docList.length; i++) {
            if (re.test(docList[i].className) ) {
                matchArray[matchArray.length] = docList[i];
            }
        }
        return matchArray;
    }
    

    (From here.)

    Even easier

    Even easier, if you want to, you can use the amazing jQuery to select elements by class name and id:

    function switchCat(cat) {
        $(".lower-ul").css({
            display:"none"
        });
        $(".lower-cat-title").css({
            color:"white"
        });
        if (cat != -1) {
            $("lower-cat-"+cat).css({
                display:"block"
            });
            $("lower-cat-title-"+cat).css({
                color:"yellow"
            });
        }
    }
    

    More cleaner!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jquery to switch between three images once you click on
I have been trying to explain the difference between switch statements and pattern matching(F#)
I'm trying to switch between the UIReturnKeyGo and the UIReturnKeyNext buttons depending on whether
I'm trying to switch between two views right now. The problem is how it
I'm trying to switch between several table views as the root of a navigation
I'm trying to switch between 2 templates on the basis of a data trigger.
I've been trying to switch from using PerlSetEnv to using custom configuration directives .
I'm really trying to switch to emacs, but learning to setup the environment is
Trying to convince someone to switch from .NET 1.1 I saw people saying that
I'm trying to suppress task switch keys (such as winkey , alt + tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.