動的に生成した要素に対してマウスオーバー(アウト)のイベントを起こす

この記事について

環境jQuery
目的動的に生成した要素にマウスオーバー(アウト)のイベントを付ける
結果$(document).on() にセレクタを渡す書き方でできた

動的に生成した要素に対してマウスオーバー(アウト)のイベントを起こすjQueryの記述

$(document).on({
"mouseenter": function(){
	$(this).removeClass("notouchstyle").addClass("touchstyle");
},
"mouseleave": function(){
	$(this).removeClass("touchstyle").addClass("notouchstyle");
}
}, ".touch-res");

参考サイト

タイトルとURLをコピーしました