我肯定错过了什么。我的脚本如下:
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
它没有得到图像的宽度。当我将上面的代码直接粘贴到控制台时,它会返回正确的值(750)。