0

Is it possible when I hover on A, change the B's style with fade out animation? Such as:

<div id="A">Div A</div>
<div>random other elements</div>
<div>random other elements</div>
<div>random other elements</div>
<div id="B">Div B</div>

I want to fade out the B's color from white to red in 2 seconds when I move my cursor to A?

I read this, it works good but there's no animation when the hover event happened.

Community
  • 1
  • 1
Vigor
  • 1,706
  • 3
  • 26
  • 47

4 Answers4

1

CSS transtition: LINK

For example:

#A {
   transition: 2s background ease;
}
Mihey Egoroff
  • 1,542
  • 14
  • 23
1

Hi I have updated the fiddle which is mentioned in the example you gave. http://jsfiddle.net/u7tYE/3461/

Added transitions to it

transition: background 2s ease;
V31
  • 7,626
  • 3
  • 26
  • 44
1
#B{
    background:orange;
}
#A:hover ~ #B {
    transition: background 2s ease;
    background: #fff
}

http://jsfiddle.net/r3hwn/

CeejeeB
  • 3,034
  • 4
  • 25
  • 32
-1

Here you have two options, option 1, CSS or option 2 jQuery.

Option 1 :

#A {
    transition:all 2s;
}

#A:hover < #B {
    color:red;
}

Option 2:

$("#A").onmouseover(function(){
    $('#B').animate({color: 'red'}, '2000');
}
$("#A").onmouseexit(function(){
    $('#B').animate({color: 'white'}, '2000');
}
DrRoach
  • 1,320
  • 9
  • 16