gpt4 book ai didi

javascript - 我如何在这里使用它与选择器

转载 作者:行者123 更新时间:2023-12-03 07:25:59 25 4
gpt4 key购买 nike

<style>
.disNone{display:none;}
.disBlock{display:block;}
</style>

<script>
$(".visitlink.item span").click(function(){
$(".summary.item").toggleClass("disNone");
$(".fullsum.item").toggleClass("disBlock");
});
</script>

<div class="wrapper">
<div class="coursebox">
<div class="summary item">summary</div>
<div class="fullsum item">fullsum</div>
<div class="visitlink item"><span>Readmore</span></div>
</div>
<div class="coursebox">
<div class="summary item">summary</div>
<div class="fullsum item">fullsum</div>
<div class="visitlink item"><span>Readmore</span></div>
</div>
</div>

我如何在点击 div 上应用类,它在两个 div 上都起作用,我如何编写代码来定位它。

最佳答案

工作演示

$(".visitlink.item span").click(function() {
$(this).closest(".coursebox").find(".summary.item").toggleClass("disNone");
$(this).closest(".coursebox").find(".fullsum.item").toggleClass("disBlock");

});
.disNone {
display: none;
}
.disBlock {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">

<div class="coursebox">
<div class="summary item">summary</div>
<div class="fullsum item">fullsum</div>

<div class="visitlink item"><span>Readmore</span>
</div>

</div>

<div class="coursebox">
<div class="summary item">summary</div>
<div class="fullsum item">fullsum</div>

<div class="visitlink item"><span>Readmore</span>
</div>

</div>

</div>

关于javascript - 我如何在这里使用它与选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com