gpt4 book ai didi

javascript - 如何抓取选择器中的所有对象?

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

喜欢

 $(":input") 

如果有多个输入,如何返回每个对象?也许在某种数组中?

此外,使用 $(":input").after(x) 时是否可以返回单个对象?

最佳答案

jQuery each

$('input').each(function () {
$(this); // A Single Input
})

或者

$('input')[0]; // HTMLElement Input

或者,jQuery's .get :

supports a little more than [...], e.g. .get(-1) returns the last element (which can be useful) - pimvdb

如何获取长度:$('input').length

关于javascript - 如何抓取选择器中的所有对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7231489/

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