javascript - Issues with .on() and AJAX -



javascript - Issues with .on() and AJAX -

this question has reply here:

event binding on dynamically created elements? 13 answers

i have these lines in header

$( document ).ready(function() { $(".thumb").hide(); $(".thumb").first().show(); $(".text" ).mouseenter(function() { $(this).prev(".thumb").show(); }).mouseleave(function() { $(this).prev(".thumb").hide(); }); });

they work fine on page load, i'm loading new html content ajax, these lines beingness ignored.

in previous questions, gentle person told me utilize .on() okay. how apply .on() code above?

i know it's dumb question of you, i'm absolute beginner , i'd appreciate it, if give helpful advice.

your code (open modifications)

$(document).ready(function() { $(".thumb").hide(); $(".thumb").first().show(); $(document).on('mouseenter',".text",function(){ $(this).prev(".thumb").show(); }) $(document).on('mouseleave',".text",function(){ $(this).prev(".thumb").hide(); }) });

javascript jquery ajax

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -