$(document).ready(function () {
var autoHeight = '';
var items = $('.iosSlider .slider .item');
var CountNumber = items.size();
var sliderHeight = 0;
for (var i = 0; i <= CountNumber - 1; i++) {
alert('hi') var itemBox = items.eq[i];
var itemHeight = itemBox.height();
alert(itemHeight);
}
});
.eq() 是一个函数,因此请使用 ()
调用它 - 因此请使用 items.eq(i)
而不是items.eq[i]
$(document).ready(function () {
var autoHeight = '';
var items = $('.iosSlider .slider .item');
var CountNumber = items.size();
var sliderHeight = 0;
for (var i = 0; i < CountNumber; i++) {
alert('hi');
var itemBox = items.eq(i);
var itemHeight = itemBox.height();
alert(itemHeight);
}
});
你也可以看看 .each() 方法来迭代一个 jQuery 对象,比如
$(document).ready(function () {
var autoHeight = '';
var items = $('.iosSlider .slider .item');
var sliderHeight = 0;
items.each(function (i, item) {
alert('hi');
var itemBox = $(this)
var itemHeight = itemBox.height();
alert(itemHeight);
})
});