So I am a bit new to jQuery - I understand the basics but my mastery is low.
I essentially have 2 rows of three col-md-4 bootstrap divs that are each linked to an image.
The jQuery I have written is absolutely so bloated but I am unsure of a way to do it better. I looked into toggleclass, toggle, hover, etc. but none achieved what I wanted.
The way I have written it has an active class on the one of the six divs with a corresponding image being "shown". I basically just add or remove the class to display:none or display:block based on whatever is being mouseovered until another div is hovered over.
This is the code, and it is basically repeated 6 times.
jQuery('.seoblock').mouseover(function() {
jQuery('.seoimage').addClass('todisplay');
jQuery('.brandingimage').removeClass('todisplay');
jQuery('.mobileimage').removeClass('todisplay');
jQuery('.optimizationimage').removeClass('todisplay');
jQuery('.supportimage').removeClass('todisplay');
jQuery('.commerceimage').removeClass('todisplay');
jQuery('.seoblock').addClass('todisplayblock');
jQuery('.brandingblock').removeClass('todisplayblock');
jQuery('.mobileblock').removeClass('todisplayblock');
jQuery('.optimizationblock').removeClass('todisplayblock');
jQuery('.supportblock').removeClass('todisplayblock');
jQuery('.commerceblock').removeClass('todisplayblock');
});
All the images are in one row and initially not shown. I have the first image displayed by using addClass.
Can you guys point me in the right conceptual direction? I tried to think of a way to achieve it with the "this" command but since the class is not added to the div on which it is hovered over, I cannot figure out how to achieve this affect.
Or maybe this code is fine to use? The only problem is I would like to have it fade in and out between images which is the only thing it does not do right now.
Here is a picture.
Here is a fiddle.
Thanks so much!