I’m always having trouble with that,
i’m loading a file with AJAX :
$.ajax({
url: fullHref,
success : function(result) {
console.log(fullHref+" was loaded via AJAX");
saveImages(result);
}
});
and trying to iterate through all images in result :
function saveImages(file){
console.log("savesImages enterd");
$(file).find('img').each(function(){
console.log("The file has this image : "+$(this).attr('src'));
});
}
}
I’ve also tried :
$('img',file)$('img',$(file))$('img',$(file).html())
Yet it doesn’t enter the loop.
Any suggestions?
I’m using Chrome, and i don’t wanna use regex.
Try
filter()instead of find:find()looks down the DOM tree which is not what you want if theimgelements in the string are all at the root level.