Zunächst einmal verzeihen Sie meine Unwissenheit über dieses Thema, aber es gibt nur so viele Möglichkeiten, dies zu tun, dass ich versuche, nur eine Möglichkeit, es zu tun.jQuery preloading Bilder Funktion
Wie funktioniert diese Geige? Ich dachte, es sollte alarmieren, wenn alle Bilder geladen sind, aber ich habe keine Bilder in den HTML-Teil gelegt.
fid: https://jsfiddle.net/mbxyoxnx/1/
function preload(files, cb) {
var len = files.length;
$(files.map(function(f) {
return '<img src="'+f+'" />';
}).join('')).load(function() {
if(--len===0) {
cb();
}
});
}
preload(["http://mydailymix.eu/wp-content/uploads/2015/06/i_love_video_games_by_cocodie-d5aokgg.jpg", "http://img07.deviantart.net/0528/i/2012/198/3/4/yo_videogames__by_ry_spirit-d57k3ay.jpg", "http://screenrant.com/wp-content/uploads/Nintendo-Video-Game-Characters.jpg","http://site-macgasm.s3.amazonaws.com/wp-content/uploads/2012/04/space-invaders.jpg"], function() {
alert('nice');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!--<img src="http://mydailymix.eu/wp-content/uploads/2015/06/i_love_video_games_by_cocodie-d5aokgg.jpg" alt="">
<img src="http://img07.deviantart.net/0528/i/2012/198/3/4/yo_videogames__by_ry_spirit-d57k3ay.jpg" alt="">
<img src="http://screenrant.com/wp-content/uploads/Nintendo-Video-Game-Characters.jpg" alt="">
<img src="http://site-macgasm.s3.amazonaws.com/wp-content/uploads/2012/04/space-invaders.jpg" alt="">
-->
Sie haben sagte ihm, eine Datei im Javascript vorzuladen. –