jQuery对象作为数组:$('#id')[0]; [英] jQuery object as a array: $('#id')[0];
本文介绍了jQuery对象作为数组:$('#id')[0];的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是有效的jQuery语法:$('#id')[0];
Is this a valid jQuery syntax :$('#id')[0];
推荐答案
要从jQuery对象中检索单个元素:
To retrieve a single element from a jQuery object:
$("div")[0]
它的缩写:
$("div").get(0)
jQuery对象在很大程度上可以用作数组,因为它也支持length
的属性,但是如果您需要一个实际的数组:
A jQuery object can be used largely as an array because it also supports a property of length
but if you want an actual array:
var arr = $("div").get();
这篇关于jQuery对象作为数组:$('#id')[0];的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文