javascript - add and remove css class on hover -
so have code , works:
$('.col-main').on('mouseenter', '.product-wrapper', function () { $( ).addclass( "js-hover" ); }); $('.col-main').on('mouseleave', '.product-wrapper', function () { $( ).removeclass( "js-hover" ); });
but want bit more elegant. this:
listcontainer.on( { mouseenter: function() { $( ).addclass( "js-hover" ); console.log( "hoooover" ); }, mouseleave: function() { $( ).removeclass( "js-hover" ); } }, productwrapper );
but can´t work :) appreciated
i think problem productwrapper
variable. try followoing.
var listcontainer=$('.col-main') var productwrapper='.product-wrapper'; listcontainer.on( { mouseenter: function() { $( ).addclass( "js-hover" ); console.log( "hoooover" ); }, mouseleave: function() { $( ).removeclass( "js-hover" ); } }, productwrapper );
Comments
Post a Comment