Link to home
Start Free TrialLog in
Avatar of richiewilmot
richiewilmotFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Jquery addClass

Hello All,

Can anyone help me out with a little jquery below, I know this isn't the right way but you should be able to tell what I'm trying to achive.

I have four images, I need three of the classes to change when I roll over an image.

If anyone knows how I can fade the effect it would be even better!

<script type="text/javascript">
$("img#front-image-one").hover(function() {
    $("img#front-image-two").addClass("hover");
      $("img#front-image-three").addClass("hover");
      $("img#front-image-four").addClass("hover");
},
  function () {
    $("img#front-image-two").removeClass("hover");
      $("img#front-image-three").removeClass("hover");
      $("img#front-image-four").removeClass("hover");
});
</script>
<script type="text/javascript">
$("img#front-image-one").hover(function() {
    $("img#front-image-two").addClass("hover");
	$("img#front-image-three").addClass("hover");
	$("img#front-image-four").addClass("hover");
}, 
  function () {
    $("img#front-image-two").removeClass("hover");
	$("img#front-image-three").removeClass("hover");
	$("img#front-image-four").removeClass("hover");
});
</script>

Open in new window

Avatar of dirknibleck
dirknibleck

You could use .animate() to fade the effect, however you would need to be modifying the style of the elements directly for that to work, not assigning a class.

What about this code isn't working for you?
Avatar of richiewilmot

ASKER

it doesn't do anything?
ASKER CERTIFIED SOLUTION
Avatar of richiewilmot
richiewilmot
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial