Jquery 如何在方法子项()之后使用方法位置()
我需要使用方法position()来获取元素A的position属性,但我只知道A是Jquery 如何在方法子项()之后使用方法位置(),jquery,position,children,Jquery,Position,Children,我需要使用方法position()来获取元素A的position属性,但我只知道A是“A”标记的子元素。 因此我使用了$(“a”).children().position()。但是失败了,因为方法children()返回的是jQuery对象。我做这个$(“a”),children()[0]。position()(我知道a是“a”标记的第一个子项)。但例外情况是这样的 未捕获的TypeError:$(…).children(…)[0]。位置不是函数 请帮助,thx$(“a”).children()
“A”
标记的子元素。
因此我使用了$(“a”).children().position()
。但是失败了,因为方法children()返回的是jQuery对象。我做这个$(“a”),children()[0]。position()
(我知道a是“a”
标记的第一个子项)。但例外情况是这样的
未捕获的TypeError:$(…).children(…)[0]。位置不是函数
请帮助,thx$(“a”).children()
匹配所有a
标记的所有子项
$(“a”).children()[0]
作为DOM元素获取第一个匹配项。相反,使用返回另一个jquery对象的.first()
$(“a”).children().first().position()