我有以下标记:
<div class="feed-item">
<div class="date-header">2012-06-03</div>
</div>
<div class="feed-item">
<div class="todo">Todo</div>
</div>
<div class="feed-item">
<div class="meeting">meeting</div>
</div>
我只想显示不同类名的 div,例如class="todo"并保持“date-header”可见。我有以下 javascript"
$('.feed-cluster,.feed-item-container').not('div:first.date-header').not(className).slideUp(speed, function(){
$('.feed-cluster' + className + ',.feed-item-container' + className).slideDown(speed);
});
一切正常,除了我试图排除第一个类名为 date-header 的 child :
.not('div:first.date-header')
谁能提出替代方案?
最佳答案
$('div.date-header').slice(1);
应该这样做。
slice
是最快函数!
Because :first is a jQuery extension and not part of the CSS specification, queries using :first cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method.
替代方法,仍然使用 querySelectorAll
函数:
$('div.date-header').not(':first');
关于javascript - JQuery 不是第一个子选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11152001/