Jump to content

IE vs. Firefox differences on div.somthing:hover


thundercade64

Recommended Posts

I have the following code in a style sheet:div.sidelink:hover, div.sidelinksmall:hover { background-color:#CC66CC; }which, when I hover over any <div class="sidelink"> or <div class="sidelinksmall"> changes the background color to that above. This works perfectly in Firefox, but it doesn't work at all in IE. What am I doing wrong, or what should I do so I can have the background of a div element change color upon hover in IE.Thanks.

Link to comment
Share on other sites

What am I doing wrong, or what should I do so I can have the background of a div element change color upon hover in IE.
You are doing nothing wrong, IE is doing everything wrong (allmost). :)IE only supports hover with a-element. I think with IE there is no other way toget hover work with other elements than javascript.
<script type="text/javascript"><!--function hover(id, color){document.getElementById(id).style.backgroundColor = color;}//--></script><div id="d1" onmouseover="hover(this.id, '#CCFFCC')" onmouseout="hover(this.id, '')">Div1</div><div id="d2" onmouseover="hover(this.id, '#CCFFCC')" onmouseout="hover(this.id, '')">Div2</div>

there is many other ways to do this with JS/DOM, but this one is easy :)Not working good if You have huge array of divs, but in "normal" doc there should be no problems.edit:do it without function and id:

<div onmouseover="this.style.background='#CCFFCC'" onmouseout="this.style.background=''">Div1</div>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...