gpt4 book ai didi

javascript - 如何在选定元素之后获取所有元素

转载 作者:搜寻专家 更新时间:2023-10-31 22:55:36 25 4
gpt4 key购买 nike

如何包含最后一个元素?

$('div.current').nextUntil("div:last").css("color", "blue");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>First</div>
<div>Second</div>
<div class="current">Third</div>
<div>Fourth</div>
<div>Fifth</div>
<div>Sixth</div>
<div>Seventh</div>

最佳答案

您可以只使用 nextAll() 代替:

$('div.current').nextAll().addClass('foo');
.foo { color: #00F; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>First</div>
<div>Second</div>
<div class="current">Third</div>
<div>Fourth</div>
<div>Fifth</div>
<div>Sixth</div>
<div>Seventh</div>

关于javascript - 如何在选定元素之后获取所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43042614/

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