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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -