我有几个div与' resultblock'类。我想要的只是展示前3个div并用jquery隐藏其他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();
});