- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
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
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…
http://codepen.io/alenabdula/pen/fjuGn
Hope that helps.
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…
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?
i find it:
var myMenu = $('.menu li');
myMenu.mouseenter(function () {
myMenu.filter('.is_hovered').removeClass("is_hovered");
$(this).addClass("is_hovered");
});
Thank you.