You forgot a $
in el
, should be $el
$(document).on('mouseenter mouseleave', '.frame', function (e) {
var $el = $(this),
mEnt = e.type == "mouseenter";
if (mEnt == true) {
$el.find('.test').removeClass('test2');
} else {
$el.find('.test').addClass('test2');
}
});
Demo here
The best solution for this can be plain CSS (and no jQuery needed), like this:
.test {
opacity:0;
}
.frame:hover .test {
opacity:1;
}
Demo here