类的第一个元素我有元素的列表是这样的:的jQuery找到唯一的ID
<article id="post-647" class="brand-search-result brand-alaffia hidden"></article>
<article id="post-647" class="brand-search-result brand-alaffia hidden"></article>
<article id="post-647" class="brand-search-result brand-alaffia hidden"></article>
<article id="post-650" class="brand-search-result brand-alter-eco hidden"></article>
<article id="post-650" class="brand-search-result brand-alter-eco hidden"></article>
<article id="post-650" class="brand-search-result brand-alter-eco hidden"></article>
现在我想的是找到的第一个每一个独特的ID,并删除隐藏类的东西。这是我在的jQuery至今:
(function(){
$("[id^=post-]").each(function(){
$(this).first(".brand-search-result").removeClass('hidden');
});
})();
唯一的问题是每一篇文章元素这是有道理的这一运行。有什么建议么?
建议:** IDS必须是唯一的** – theblindprophet
,如果你想选择的唯一的字符串使用类 – fdfey
@theblindprophet差了一点更多的元素 - 除了,它应该比一个建议了。 – Alfie