是将多个选择器分配给一个数组吗? [英] Is assigning multiple selectors into one var an array?
本文介绍了是将多个选择器分配给一个数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否将多个元素分配给一个数组中的变量?
Is assigning multiple elements into one variable considered an array?
var $myList = $("#elOne, #elTwo, #elThree, etc");
如果不是,那是什么?另外,在变量名中添加'$'只是为了提醒开发人员这是元素引用变量的标准做法吗?
If not, what is it? Also, is adding the '$' to the var name just standard practice to remind developers that this is an element reference variable?
推荐答案
$
是为了提醒开发人员此变量保存对jQuery对象的引用.
$
is to remind developers that this variable holds reference to a jQuery object.
是的,$myList
将把选择器应用到的所有元素作为数组保存(尽管它是一个jquery对象,但它像数组一样保存它们)
And Yes, $myList
will hold all the element that your selector applied to as an array(although it's a jquery object it just holds them like an array)
这篇关于是将多个选择器分配给一个数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文