gpt4 book ai didi

javascript - find() 伪元素 jquery

转载 作者:行者123 更新时间:2023-12-01 01:23:00 24 4
gpt4 key购买 nike

html:

<div id="pai_pergunta_0" class="col s12 card-panel hoverable box-pai" data-id="0" data-tipo="TEXT">
</div>

<div id="pai_pergunta_1" class="col s12 card-panel hoverable box-pai" data-id="1" data-tipo="RADIO">
</div>

<div id="pai_pergunta_2" class="col s12 card-panel hoverable box-pai" data-id="1" data-tipo="CHECKBOX">
</div>

我的表单是动态的,我需要在每个 data-tipo="TEXT"之后删除一个 div。如果我想找到“box-pai”类,我只需找到('.box-pai'),但是如何找到伪元素 data-tipo="TEXT"

最佳答案

您可以通过属性选择,然后使用.next("div")查找下一个div...

$("[data-tipo=TEXT]").next("div").remove();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div id="pai_pergunta_0" class="col s12 card-panel hoverable box-pai" data-id="0" data-tipo="TEXT">
TEXT
</div>

<div id="pai_pergunta_1" class="col s12 card-panel hoverable box-pai" data-id="1" data-tipo="RADIO">
RADIO
</div>

<div id="pai_pergunta_2" class="col s12 card-panel hoverable box-pai" data-id="1" data-tipo="CHECKBOX">
CHECKBOX
</div>

关于javascript - find() 伪元素 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54074539/

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