gpt4 book ai didi

javascript - 如何使用Jquery访问下2层的div元素

转载 作者:行者123 更新时间:2023-11-28 19:25:24 25 4
gpt4 key购买 nike

我一生都无法弄清楚如何访问第一个 div,其文本为“我想要这个”,以 div1 的 id 开头

我的尝试:

$("#div1").first().first().html();

这是一个例子

<div id="div1">
<div class="row">
<div class="another">I want this one</div>
<div class="another">Not this one</div>
</div>
</div>

最佳答案

试试这个

1.

 $("#div1 .another:first").html();

2.

$("#div1 .another").first().html();

3.

$("#div1 .another").eq(0).html();

Example

关于javascript - 如何使用Jquery访问下2层的div元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27987621/

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