Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Trying to add another addClass(); when element is clicked in jQuery Re: Trying to add another addClass(); when element is clicked in jQuery

#118340
TheDoc
Member

I think you’re going about it wrong. Instead of changing `.val-google` to `.active-google` you could just focus on the parent class/hover state. Change all of the values to just have a common class like ‘.value’, then you you can change the style of it based on its parent:

.li:hover .value, .this-item-is-dropped-down .value {
/* styles */
}

In fact, you should be removing the majority of jQuery that you’re using. Let’s see if I can whip up a quick Pen…