gpt4 book ai didi

jQuery: $ ('#id' ).find ('> a' )... 到底找到什么?

转载 作者:行者123 更新时间:2023-12-01 06:52:38 25 4
gpt4 key购买 nike

我确信有人会更改我的标题,但我很喜欢它。

无论如何,赫克托这是做什么的(正如我七岁的 child 会说的那样)?

$('#id').find('> a')...

顺便说一句,我知道 $('#parent > .child')$('#parent').children('.child') 相同> (如解释 here ),但我从来没有使用过它。

最佳答案

在没有指定父级的情况下使用 > a 实际上是不推荐使用的语法,因为正如您所发现的,它具有不明确的语义。 .find('> a') 实际上相当于 .children('a')

来自http://api.jquery.com/child-selector/

Note: The $("> elem", context) selector will be deprecated in a future release. Its usage is thus discouraged in lieu of using alternative selectors.

[记住$(sel, context)相当于$(context).find(sel)]

关于jQuery: $ ('#id' ).find ('> a' )... 到底找到什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12444574/

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