Ok, my JQuery assignment requires preloading images. I'm using Netbeans and tried several JQuery tutorials, but the code below is still not preloading the images--it always instead loads the image directly. JQuery Code's below, followed by the HTML provided for this assignment, and I'm using Netbeans.
https://i.imgur.com/Trkchty.png
(The HTML was automatically rendering itself)
JavaScript:
```
$("document").ready(function() {
var pics =[
["images/casting1.jpg"]
["images/casting2.jpg"]
["images/catchrelease.jpg"]
["images/fish.jpg"]
["images/lures.jpg"]
];
var count = pics.length;
var cur = 1;
$("#image_list a").each(function(){
var tempimage = new Image();
//var imageURL = $(this).attr("href");
tempimage.src = $(this).attr("href");
});
//preload images
var $img = new Array();
for(var i=0;i<count-1;i++){
var $image = $("<img>").attr("src",pics[0]);
$imgs.push($('<img>').attr('src', pics[0]));
}
$("#pics_holder").append("<li>");
$("#pics_holder li").css("width",(count)*990);
for(var i=0;i<count-1;i++) {
var $li = $("<li>").append($imgs);
$("#pics_holder li").append($li);
}
$("#image_list a").click(function(evt){
var imageURL = $(this).attr("href");
$("#image_list a").attr("src", imageURL);
var caption = $("this").attr("title");
$("#caption").text(caption);
evt.preventDefault();
}); //end click```
```
https://i.imgur.com/Trkchty.png
(The HTML was automatically rendering itself)
Last edited by a moderator: