gpt4 book ai didi

javascript - 具有特定任务的文本分析器

转载 作者:太空宇宙 更新时间:2023-11-04 07:20:27 26 4
gpt4 key购买 nike

这是轮盘游戏,您可以在其中获得 "coin coin-ct""coin coin-t""coin coin-bonus"。如果可能的话,我怎么知道连续重复 "coin coin-ct" 变量的 3 或 4 次的完整时间?本人新手,请谅解。

作为:

<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721574 - 13</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721573 - 11</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721572 - 10</div>
</div>

完整代码示例(现实生活中更多):

<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721574 - 13</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721573 - 11</div>
</div>
<div class="icon-box">
<div class="coin coin-bonus"></div>
<div class="round">#2721572 - 0</div>
</div>
<div class="icon-box">
<div class="coin coin-t"></div>
<div class="round">#2721571 - 6</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721570 - 9</div>
</div>

最佳答案

对您拥有的每一行使用 JQuery 选择器,选择它的子级,它们的类是 coin coin-ct

$(".row")

一个类选择器,它获取类为 row 的所有元素。 (class="行")

$(".row").each(函数(itm){})

所有元素的迭代器都有 row 类。

$(this).children("div.icon-box")

用于选择 div 且具有 icon-box 类的所选元素的所有子元素

类似下面的内容:

$(".row").each(function(itm) {
$(this)
.children("div.icon-box")
.each(function(obj) {
console.log($(this).children(".coin.coin-ct").length)
});
console.log("-----------------------------");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721574 - 13</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721573 - 11</div>
</div>
<div class="icon-box">
<div class="coin coin-bonus"></div>
<div class="round">#2721572 - 0</div>
</div>
<div class="icon-box">
<div class="coin coin-t"></div>
<div class="round">#2721571 - 6</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721570 - 9</div>
</div>
</div>
<div class="row">
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721574 - 13</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721573 - 11</div>
</div>
<div class="icon-box">
<div class="coin coin-bonus"></div>
<div class="round">#2721572 - 0</div>
</div>
<div class="icon-box">
<div class="coin coin-t"></div>
<div class="round">#2721571 - 6</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721570 - 9</div>
</div>
</div>
<div class="row">
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721574 - 13</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721573 - 11</div>
</div>
<div class="icon-box">
<div class="coin coin-bonus"></div>
<div class="round">#2721572 - 0</div>
</div>
<div class="icon-box">
<div class="coin coin-t"></div>
<div class="round">#2721571 - 6</div>
</div>
<div class="icon-box">
<div class="coin coin-ct"></div>
<div class="round">#2721570 - 9</div>
</div>
</div>

阅读JQuery selectors , each function , children

希望对你有帮助。

关于javascript - 具有特定任务的文本分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50321734/

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