javascript - Issues with .on() and AJAX -
javascript - Issues with .on() and AJAX -
this question has reply here:
event binding on dynamically created elements? 13 answersi 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
Post a Comment