troubleshooting Question

Jquery addClass

Avatar of richiewilmot
richiewilmotFlag for United Kingdom of Great Britain and Northern Ireland asked on
JavaScriptjQueryJScript
3 Comments1 Solution539 ViewsLast Modified:
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>
ASKER CERTIFIED SOLUTION
richiewilmot

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros