Forums

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

Home Forums JavaScript [Solved] Jquery – add class on hover

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #159909
    Hamed
    Participant

    Hi, how can i add a class to the element when mouse get on hover it and that element keep class until mouse goes on another element then remove added class and add it to other on hovered element ?

    sorry for my bad eng, i hope you understand my mean…

    #159912
    Alen
    Participant
    #159913
    Hamed
    Participant

    Thank you, it’s work perfectly but when mouse out added class removed!
    i want keep class until mouse goes on another li, if not don’t remove added class…

    #159922
    Paulie_D
    Member

    i want keep class until mouse goes on another li, if not don’t remove added class…

    That would not be appropriate…you should not apply changes on hover that you want to remain in place when the hover is removed.

    Can you explain why this would be required?

    #159923
    Hamed
    Participant

    i find it:

    var myMenu = $('.menu li');
    
    myMenu.mouseenter(function () {
        myMenu.filter('.is_hovered').removeClass("is_hovered");
        $(this).addClass("is_hovered");
    });
    

    Thank you.

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