[英]$$ and $ in PrototypeJs
I am new to PrototypeJs. 我是PrototypeJs的新手。 I am searching for different tutorials to increase my knowledge for this. 我正在寻找不同的教程来增加我的知识。 Suddenly I observed that Magento also using Prototype with double $$ (dollar signs) instead single $ (dollar sign). 突然间,我发现Magento也使用Prototype和双$$(美元符号)而不是单个$(美元符号)。 So what is the different between single and double dollar sign in prototype. 那么单原子和双美元签到原型有什么不同。 Assume the following example 假设以下示例
function test(){
div = $("div");
alert(div.innerHTML);
}
but in magento (also found in many tutorials, peoples are using $$), like 但是在magento(也在许多教程中找到,人们使用$$),就像
function test(){
div = $$("div");
alert(div.innerHTML);
}
Any body to help me out with this. 任何帮助我解决这个问题的机构。
"$" stands for select by ID. “$”代表按ID选择。
"$$" stands for select by class and by tag. “$$”代表按类和标签选择。
For more info: http://www.webmonkey.com/2010/02/get_started_with_prototype/ 欲了解更多信息: http : //www.webmonkey.com/2010/02/get_started_with_prototype/
That says: 说的是:
$('div') // document.querySelector('div') <----single first element in collection
$$('div') // document.querySelectorAll('div') <----collection of all divs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.