gpt4 book ai didi

jquery - 帮助理解 JQuery 属性等于选择器

转载 作者:行者123 更新时间:2023-11-30 23:49:11 25 4
gpt4 key购买 nike

我想找一个<td role="foo" class="one two three four"><div id="myid">

这两个选择器的工作原理:

$('#myid td[role=foo]')

$('#myid .two')

但是这个没有,为什么?

$('#myid .two td[role=foo]')

最佳答案

因为选择器字符串中有空格is a descendant-selector .

您需要执行以下操作:

$('#myid td.two[role=foo]')

按照您的方式,您正在搜索 <td role="foo"> .two后代元素.

关于jquery - 帮助理解 JQuery 属性等于选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3814966/

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