How to create function to dynamically created ids

How to create function to dynamically created ids

Please I will like to know how to create a function or event listener to check for dynamically created div elements using their ID.
I have a dynamically created page which contains fetched content from a jquery ajax backend. What i want to do now is use set interval and refresh the content of the div should incase the content was changed by another user. e.g.
  1. <div id= "product1">Content of product 1</div>
  2. <div id="product2">Content of product 2</div>
but the id is being set from a php backend that is fetched from and can change using the pagination so that if only products from 1 to 5 is displayed the action listener would listen for each "product" and update the div but if the page is changed to 2 which contains product 6 to 10, the function automatically start listening for products with id 6 to 10 dynamically.