jQuery fresh ALL rows from PHP loop

Solution 1:

You need to move the script out from the loop completely. Have ONE version of the script that delegates like this

$("#container").on("click", ".live-users-more",function () { 
  const item_id = $(this).prev().attr("id");  .... 

and then change

<div id="live-users-more-<?=intval($row["item_id"])?>"></div> 

to

<div class="live-users-more"></div> 

where you have a

<div id="container"></div> 

that wraps all the live user divs