我想显示/隐藏一个 2 兄弟元素onclick
。
在页面上,我有多个detailLinksItem
将包含此显示/隐藏功能,因此只需要选择兄弟姐妹。我需要onclick
为.style.display = 'block';
兄弟姐妹.showLess
和.moreLinksContainer
.
<div class="detailLinksItem">
<div class="searchIcon"></div>
<a href="#"></a>
<a href="#"></a>
<div class="detailDate"></div>
<div class="arrow-down"></div>
<a href="#" class="showMore" onclick="showStuff(moreLinksContainer); return false;">Show more</a>
<a href="#" class="showLess" onclick="hideStuff('moreLinksContainer'); return false;" style="display: none;">Show less</a>
<div class="moreLinksContainer" style="display: none;">
<ul>
<li><a href="#">Link Title Goes Here!!</a><div class="moreDetailDate">6 hours</div></li>
<li><a href="#">Link Title Goes Here!!</a><div class="moreDetailDate">1 day</div></li>
<li><a href="#">Link Title Goes Here!!</a><div class="moreDetailDate">3 days</div></li>
<li><a href="#">Link Title Goes Here!!</a><div class="moreDetailDate">1 week</div></li>
</ul>
</div>
</div>