javascript - Jquery 'each' does not applicable on ajax loaded dom -
i trying refresh google advertisement, inside div. have added common css class named 'adslot' div. few divs loads ajax. @ document ready, when call div's jquery each function, applicable divs, has loaded before ajax call. example, if give number of available '.adslot',
alert($('.adslot').length);
output: 5, correct. 3 of divs generated before ajax call, , 2 of generated after ajax call.
at same this, if write -
$('.adslot').each(function() { var id = $(this).attr('id'); alert(id); });
i alert of 1st 3 divs id, generated before ajax call.
has there way read 5 divs ids jquery?
try code in success callback
like
$(function(){ $.ajax({ url:...., data:..., success:function(data){ $('.adslot').each(function() { var id = this.id; alert(id); }); } }); });
Comments
Post a Comment