gpt4 book ai didi

jquery:反向迭代children()

转载 作者:行者123 更新时间:2023-12-03 23:01:29 24 4
gpt4 key购买 nike

我需要反向迭代 jquery 子元素:

$("#parent").children().each(function() {
# do stuff
})

但相反。

我见过使用reverse()和get()

$($("li").get().reverse()).each(function() { /* ... */ });

但似乎无法使其与 Children() 一起使用。

最佳答案

使用与之前相同的策略:

$($("#parent").children().get().reverse()).each(function() {
# do stuff
})

或者稍微更简洁一点:

[].reverse.call($("#parent").children()).each(function() {
# do stuff
})

关于jquery:反向迭代children(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16609882/

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