-1

I am all images from a folder using javascript. I followed instructions from this link. How to load all the images from one of my folder into my web page, using Jquery/Javascript

But when i try to get the image length and geight it returns 0 here is my code.

window.onload = function() { 
var dir = "images/";
var fileextension = ".jpg";
$.ajax({
    //This will retrieve the contents of the folder if the folder is configured as 'browsable'
    url: dir,
    success: function (data) {
        //Lsit all png file names in the page
        $(data).find("a:contains(" + fileextension + ")").each(function () {
            var filename = this.href.replace(window.location, "").replace("http:///", "");
            $("#gall").append($("<img src=" + dir + filename + "></img><span>Picture description</span>"));
            this.length;
        });
                pgal.display(); 
    }
});

}

In pgal.display(), i am simply writing width and height to console.

Community
  • 1
  • 1
sheldon cooper
  • 455
  • 2
  • 8
  • 22

1 Answers1

0

You're need something like this:

$("#gall").find('img').on('load', function(event) { console.log(event.target) });
11111000000
  • 193
  • 2
  • 9