$(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);
}
});
答案 0 :(得分:1)
.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);
})
});