Forums

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

Home Forums JavaScript jQuery ToggleClass Not Stopping

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33143
    StephBertha
    Participant

    Hi there,

    I have this:

    $(function() {
    $('div#how-does li a').hover(
    function() {
    $(this).stop().toggleClass('large-circle');
    }
    );
    });

    But when I rollover my link several times back and forth, the class still sticks. I thought adding

    stop()

    fixed that? I also added

    stop(true, true)

    , and remains the same. Thoughts?

    #72791
    akurtula
    Participant

    hi

    i think you need to add 2 class names. like this example from jquery documentation:

    $(‘#foo’).toggleClass(className, addOrRemove)

    so you need to add something like

    $(this).toggleClass(‘large-circle’, ‘normalstate’);

    and style the new class

    #72758
    StephBertha
    Participant

    Thanks Akurtula for responding!

    I just tried, but it does do the same thing, although your response would make sense. Weird?

    #72653
    akurtula
    Participant

    hey how about this

    $(‘div#how-does li a’).hover(

    maybe the UL you missed might be the problems

    over here it works:

    http://jsfiddle.net/f5hqk/

    ps, I forgot you dont need my previous example for a hover state :)

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