[英]Javascript confusion
var allRapidSpells = $$('input[value^=RSW]');
谁能告诉我那是什么?
I would venture to guess that you're using MooTools , a JavaScript framework. 我冒昧地猜测您正在使用MooTools (JavaScript框架)。 The
$$()
function is used to select an element (or multiple elements) in the DOM. $$()
函数用于选择DOM中的一个元素(或多个元素)。
More specifically, the $$('input[value^=RSW]');
更具体地说,
$$('input[value^=RSW]');
syntax is selecting all input
elements whose value
attribute starts with RSW
. 语法是选择其
value
属性以RSW
开头的所有input
元素。
Other attribute selectors include: 其他属性选择器包括:
=
: is equal to =
:等于 *=
: contains *=
:包含 ^=
: starts-with ^=
:开始于 $=
: ends-with $=
:结尾为 !=
: is not equal to !=
:不等于 ~=
: contained in a space separated list ~=
:包含在以空格分隔的列表中 |=
: contained in a '-' separated list |=
:包含在以“-”分隔的列表中 Edit: It looks as though Prototype , another JavaScript framework, uses the same syntax . 编辑:似乎另一个JavaScript框架Prototype使用相同的语法 。
返回所有具有RSW开头的值的输入
It calls the function named '$$' with the parameter 'input[value...' and assigns the returnvalue of that function to the var allRapidSpells. 它使用参数“ input [value ...”调用名为“ $$”的函数,并将该函数的返回值分配给var allRapidSpells。
Javascript doesn't consider the '$' to be a reserved character, which jQuery makes excellent use of. Javascript并不认为'$'是保留字符,jQuery很好地利用了该字符。
看起来它使用了一些使用JavaScript库的CSS选择器,这些CSS选择器返回值以RSW开头的所有输入标签。
calls a method on the windows object called $$ and passes a string argument to it, which appears to be an xpath expression. 在Windows对象上调用名为$$的方法,并向其传递一个字符串参数,该参数似乎是xpath表达式。
which returns input tags that contain an attribute called value starting with RSW. 它将返回包含以RSW开头的名为value的属性的输入标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.