Description
For example,can I transform test1() to test2()?
function test1() {
$(“img”).mouseenter(function(e) {
$(this).css(“opacity”, 0.5);
}).mouseout(function(e) {
$(this).css(“opacity”, 1.0);
});
}
function test2() {
$(“img:odd”).mouseenter(e => {
$(this).css(“opacity”, 0.5);
}).mouseout(e => {
$(this).css(“opacity”, 1.0);
});
}
You can use
event.target
(or based on the code above,e.target
), instead ofthis
though.