Update jQuery Function

Is it possible to update a function every x seconds or update it on one event?

I will explain:

I have a function that does pagination on my site, inside each div, which are “pages”. I have some photos in which I added LightBox.

Everything works well on the first div (page), but when I change the page, it no longer works.

I tried to fix as follows:

$('.pagination a').click(function () {
    initShadow();
});

Thus, it works on the Load page and on the first page that I am changing than at the stop.

Therefore, I need to fix this problem, every time I change the "page", I would like it to work perfectly.

Can I update a function every x seconds or update it every time I press the pagination buttons?

+3
2

, setInterval() - , . .

setInterval(functionToExecute, 1000); 
//this would call 'functionToExecute' every 1000 milliseconds

.live() .click() , . , , , 1 click.

$('.pagination a').live('click',function () {
    initShadow();
});
+6

.on() jQuery.

$(document).on('click', '.pagination a', function () {
    initShadow();
});

, .

0

Source: https://habr.com/ru/post/1790102/


All Articles