1
我有幾個帶有'resultblock'類的div。我只想顯示前3個div並用jquery隱藏其他人。但下面的代碼不起作用。你能幫我找到我的錯誤嗎?JQuery隱藏了前3個div元素
//pushing all the divs into array
var results_list = [];
$('.resultblock').each(function() {
results_list.push(this);
});
//hide all the divs
$('.resultblock').each(function() {
$(this).hide();
});
//show the first 3 divs
var i;
for (i = 0; i < 3; ++i) {
$(results_list[i]).show();
});