この記事について
| 環境 | jQuery |
|---|---|
| 目的 | 動的に生成した要素にマウスオーバー(アウト)のイベントを付ける |
| 結果 | $(document).on() にセレクタを渡す書き方でできた |
動的に生成した要素に対してマウスオーバー(アウト)のイベントを起こすjQueryの記述
$(document).on({
"mouseenter": function(){
$(this).removeClass("notouchstyle").addClass("touchstyle");
},
"mouseleave": function(){
$(this).removeClass("touchstyle").addClass("notouchstyle");
}
}, ".touch-res");
