我试图+Details在单击并显示一个元素后隐藏它xClose,反之亦然,但它不起作用。此外,当我单击+Details所有 div 时,即使我使用了each()函数。当您单击xClose我想要显示eventInfo文本时,但我什xClose至无法显示文本。
$('.openInfo').each(function (index) {
$(this).click(function () {
$('.eventInfo').toggleClass('show');
$('openInfo').toggleClass('hide');
$('closeInfo').toggleClass('show');
});
});
$('.closeInfo').each(function (index) {
$(this).click(function () {
$('.eventInfo').toggleClass('show');
$('closeInfo').toggleClass('hide');
$('openInfo').toggleClass('show')
});
});
.event{
margin-bottom: 30px;
}
.eventInfo, .closeInfo{
display: none;
}
.show{
display: block;
}
.hide{
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="event">
<p class="openInfo"><span>+</span>Details</p>
<p class="eventInfo"> Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
<p class="closeInfo"><span>x</span>Close</p>
</div>
<div class="event">
<p class="openInfo"><span>+</span>Details</p>
<p class="eventInfo"> Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
<p class="closeInfo"><span>x</span>Close</p>
</div>
暮色呼如
相关分类