Мне что-то не хватает. Мой сценарий выглядит следующим образом:Установка переменных не работает на загрузке страницы, но через консоль?
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);
Выход:
[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
Он не получает ширину изображения. Когда я вставляю вышеуказанный код DIRECTLY в консоль, он возвращает правильное значение (750).
'$ (window) .load (function() {...});' – epascarello