CSS style changer

Discussion in 'JavaScript' started by xira, Sep 20, 2008.

  1. #1
    Hi, I need a script for a CSS style changer since the style I need to change onmouseover... is a different <div> than where the link is. The link itself already changes via CSS. I just can't target the second object.

    www.xira.net/zaidler shows the page I am talking about. I need the menu item to change the image of the corresponding subject (one of four images in center.)
     
    xira, Sep 20, 2008 IP
  2. xira

    xira Active Member

    Messages:
    315
    Likes Received:
    8
    Best Answers:
    4
    Trophy Points:
    68
    #2
    I found a script!!! Now I have a technical question...

    Why would the script work 100% when the page is refreshed. When rolling over the menu items, moving on to the images works fine. However, after rolling over the images, then the menu items do not work anymore (changing the images.)

    <script language="javascript" type="text/javascript">
    function ChangeClass(image, newClass) {
    if (document.getElementById) {
    document.getElementById(image).className = newClass;
    }
    }
    function ChangeClass_menu(menu, newClass) {
    if (document.getElementById) {
    document.getElementById(menu).className = newClass;
    }
    }
    document.onselectstart = new Function("return true");
    </script>

    +++++++++++++++++++ IMAGE +++++++++++++++
    <div class="img01" id="image1"><a href="#" onmouseover="ChangeClass_menu('menu1','sidemenu1ro'); this.className='img01ro';" onmouseout="ChangeClass_menu('menu1','sidemenu1'); this.className='img01';"><img src="images/spacer.gif" width="217" height="217" alt="image" /></a><a href="#"><img src="images/spacer.gif" alt="figurative" name="Image01" width="217" height="217" border="0"></a></div>

    +++++++++++++++++++ MENU ITEM +++++++++++++++
    <div class="itemcontainer1"><a href="#" class="sidemenu1" onmouseover="ChangeClass('image1','img01ro'); this.className='sidemenu1ro';" onmouseout="ChangeClass('image1','img01'); this.className='sidemenu1';" id="menu1">Figurative</a></div>
     
    xira, Sep 20, 2008 IP
  3. xira

    xira Active Member

    Messages:
    315
    Likes Received:
    8
    Best Answers:
    4
    Trophy Points:
    68
    #3
    Nevermind, figured it out.
     
    xira, Sep 20, 2008 IP