When I create an image in jQuery, set i's attributs with .attr() and then wait for it to load with .load() before animating the script randomly stops in IE. It always fails before the .load().
Any help would be very much appreciated. Even a different way of doing things would be helpful.
Thanks.
$('<img />')
.attr({
src: new_src,
width: '820',
height: '575',
alt: '',
'class': 'bg_image'
})
.load(function(){
//append image to #main2
$('#main2').append( $(this) );
//animate backgrounds
$("#main2").animate({left: $main_left + "px"}, 'slow');
$("#main").animate({left: new_left + "px"}, 'slow', function() {
if($rand){
document.location = $href + '?i=' + $rand;
} else {
document.location = $href;
}
});
});