什么是“.el”与 JavaScript/HTML/jQuery 的关系?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10507100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is ".el" in relationship to JavaScript/HTML/jQuery?
提问by Zhao Li
I couldn't find much from Googling, but I'm probably Googling the wrong terms.
我在谷歌上找不到太多东西,但我可能在谷歌上搜索了错误的术语。
I'm trying to understand what the "el" in "$.el" is from here: http://joestelmach.github.com/laconic/
我试图从这里了解“$.el”中的“el”是什么:http://joestelmach.github.com/laconic/
$.el.table(
$.el.tr(
$.el.th('first name'),
$.el.th('last name')),
$.el.tr(
$.el.td('Joe'),
$.el.td('Stelmach'))
).appendTo(document.body);
Thanks in advance!
提前致谢!
回答by undefined
el
is just an identifier and it refers to an element, a DOM element, which is a convention in that library.
el
只是一个标识符,它指的是一个元素,一个 DOM 元素,这是该库中的约定。
回答by Sérgio Michels
You can obtain the explanation seeing the sourceof the project in the github:
你可以在github中查看项目源获得解释:
// If we're in a CommonJS environment, we export our laconic methods
if(typeof module !== 'undefined' && module.exports) {
module.exports = laconic;
}
// otherwise, we attach them to the top level $.el namespace
else {
var dollar = context.$ || {};
dollar.el = laconic;
context.$ = dollar;
}
The code means that $.el namespace will have the function laconic()
and this function create elements using document.createElement
and append to the body.
代码意味着 $.el 命名空间将具有该函数,laconic()
并且该函数使用创建元素document.createElement
并将其附加到主体。
回答by Joe Stelmach
el
is a function that's been placed on the $
object, and can be invoked to generate DOM elements:
el
是一个放置在$
对象上的函数,可以调用它来生成 DOM 元素:
$.el('table')
el
also acts as a placeholder for other objects, like the table
function:
el
还充当其他对象的占位符,如table
函数:
$.el.table()
回答by dubvfan87
It creates a tree of elements and appends them to body
它创建一个元素树并将它们附加到 body