Click to See Complete Forum and Search --> : controlling div background from a seperate div


wynton_ca
07-09-2003, 12:11 PM
Hey all,

Im hip to changing the background of an element, as long as it is the same element (say, changing the background of a table cell). However Im having a problem deciphering how to change the background color of one div layer while mousing over another div layer. So something like below:

<div id="div_1" onmouseover="background-color change">
content
</div>

<div id="div_2" onmouseover="change div 1 background color">
content
</div>

So essentially I want div 1 to rollover a different color - easy enough. However how do I specify div_2 to control div_1's background-color?

wynton

pyro
07-09-2003, 12:37 PM
Try something like this:

<div id="div1" style="border: 1px solid;">test</div>
<div id="div2" style="border: 1px solid;" onmouseover="document.getElementById('div1').style.backgroundColor='darkblue';" onmouseout="document.getElementById('div1').style.backgroundColor='white';">test2</div>

wynton_ca
07-09-2003, 12:40 PM
word! thanks!

pyro
07-09-2003, 12:43 PM
You're welcome... :)