Problem with jQuery mouseover / mouseout

I have a page with a list of elements (elements) of elements that are drawn dynamically, so live . When the user rolls the element, I would like them to switch to the "on" class, and then when they are collapsed (mouseout), the element returns to its normal state. Elements are turned on with the line of code below, but not turned off. Suggestions?

$('.item').live('mouseover', function(){$(this).switchClass('item','item_on', 500);});
$('.item_on').live('mouseout', function(){$(this).switchClass('item_on','item', 500);});

Thanks!

+3
source share
1 answer
$('.item').live('mouseover',
function(){$(this).addClass('item_on');});
$('.item').live('mouseout',
function(){$(this).removeClass('item_on');});

, , switchClass jQuery UI jquery, script, , .item, .item_on .

, , , , http://cherne.net/brian/resources/jquery.hoverIntent.html addClass/removeClass.

+1

Source: https://habr.com/ru/post/1721660/


All Articles