【发布时间】:2015-06-19 00:06:10
【问题描述】:
目前正在运行。但我想知道为什么这不会影响.filteritem 中每个.container 的CSS。它只找到页面上的第一个,而我想在.filteritem 中更改所有.container。
$(document).ready(function () {
$('#select').on('change', function () {
if (this.value == 'alltopics') {
$('.filteritem').fadeIn(500);
} else {
var elems = $('.filteritem[data-aa_eventtopic="' + this.value + '"]');
$('.filteritem').not(elems).closest('.filteritem').fadeOut(500);
elems.closest('.filteritem').fadeIn(500);
//HERE
$('.filteritem').each(function () {
setTimeout(function () {
$('.container').filter(':visible').first().css({
borderTop: 'none',
paddingTop: '0px'});
}, 501);
});
}
});
});
【问题讨论】:
-
.first() 可能是这里的罪魁祸首。另外,从技术上讲,它看起来像是针对所有 .container 而不考虑其父级。也许你想要 $(this).find('.container')