javascript - Setting Variables Does Not Work on Page Load, but Does Through Console? -


i must missing something. script follows:

var slideshowul = jquery('div.slideshow').css('overflow', 'hidden').children('ul'),     imgs = slideshowul.find('img'),     imgwidth = imgs[0].width,     imgslen = imgs.length,     current = 0;      console.log(slideshowul);     console.log(imgs);     console.log(imgwidth);     console.log(imgslen);     console.log(current); 

the output is:

[ul, prevobject: p.fn.p.init[1], context: document, selector: "div.slideshow.children(ul)", constructor: function, init: function…] [img, img, img, img, prevobject: p.fn.p.init[1], context: document, selector: "div.slideshow.children(ul) img", constructor: function, init: function…] 0 4 0  

it not getting width of image. when paste above code directly console, returns correct value (750).

width of 0 means reading value before images have loaded. call on window onload , not ready/inline.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -