After sending AJAX requests and receiving HTML with multiple div elements (.card), I am using .append to add new .card elements after each request, creating an infinite scroll effect. However, I am facing issues when trying to use .each to iterate over all .card elements on the page after one, two, three, etc. AJAX requests.
$( document ).ready(function() {
$('.card').each(function(i) {
addMarker(i);
}
});
and
$( document ).ajaxComplete(function() {
$('.card').each(function(i) {
addMarker(i);
}
});
This approach is not functioning as expected.
With each AJAX request, I am observing that the count begins from zero on the new .card divs.