在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ mouseenter, leave 這種怎麼簡寫?。?/span>

mouseenter, leave 這種怎麼簡寫?。?/h1>
$(".help_cover").mouseenter(function(event) {
  $(".layout_help_cover").fadeIn();
});
$(".help_cover").mouseleave(function(event) {
  $(".layout_help_cover").fadeOut();
});

請問這種代碼能怎麼簡寫?我想到是這樣了,沒有別的方式,有大神知道還能再簡寫嗎?

回答
編輯回答
莫小染
var $aniCover = $('.layout_help_cover');
$('.help_cover').on({
    mouseenter: function() {
        $aniCover.fadeIn();
    },
    mouseleave: function() {
        $aniCover.fadeOut();
    },
});

個人覺得jQ的事件簡寫其實很雞肋。。。(當(dāng)然放在文檔里提醒你有什么事件可以用這點(diǎn)還是有一定現(xiàn)實意義的。)

2017年1月3日 23:54
編輯回答
骨殘心
$(".help_cover")
.mouseenter(function(event) {
  $(".layout_help_cover").fadeIn();
})
.mouseleave(function(event) {
  $(".layout_help_cover").fadeOut();
});

略微簡化一點(diǎn)點(diǎn)

2018年8月16日 10:47