JQuery - Preloading Images

Discussion in 'Javascript' started by Brom2885, Apr 18, 2019.

  1. Brom2885


    Apr 1, 2019
    Likes Received:
    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.

    Code (Javascript):
    $("document").ready(function() {
        var pics =[
        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 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");
        }); //end click```

    (The HTML was automatically rendering itself)
    Last edited by a moderator: Apr 18, 2019
    Brom2885, Apr 18, 2019
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.