Please tell me, I used to use the live function or the livequery module to access elements loaded with AJAX.

Need to do something like:

$('img').livequery(function() { $(this).fancybox(); }); 

How to do this in jQuery 3. *?

    1 answer 1

    You can use on , for example:

     $('img').on('click',function() { $(this).fancybox(); }); 

    If you need to reinitialize Fancybox after an AJAX request, simply insert the call after the AJAX request ends (for example)

     ...... 'success' : function (data) { $('img').fancybox(); } 
    • Yes, it works if you need to catch a click, but, I need to hang up, for example, fancybox. - Tran
    • Ie without any action to activate the fancybox for the picture? - Arsen