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

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #41488

    See how when you hover over the boxes, they turn blue; as well as the rounded rectangle with the number in it. Then, if you click “Google”, a menu drops down and the box on top stays blue, but the rounded rectangle with the number inside does not.

    https://dl.dropbox.com/u/55017445/Stock/index.html#

    (P.S. sorry for the weird id and class names)

    #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…

    #118341

    Ohh, I see! I just started learning jQuery and implementing it into simple projects like this.

    #118342
    TheDoc
    Member

    I removed a bunch of code: http://codepen.io/ggilmore/pen/GaJcK

    It’s not perfect, but it should show you how you can continue.

    You also had some bad practices going on with your list items by having the `` wrapping the `

  • `, it should be the other way around.
#118344

@TheDoc Hey, the JS was accidentally deleted when I tried to copy it, can you do that part again, please? Thank you so much for you time helping me!

#118361
TheDoc
Member

If you go to the link I posted above it should be there.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.