What Is ". El" in Relationship to Javascript/Html/jQuery?
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: $. El. Table( $...
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:
$.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!
4 Answers
el is just an identifier and it refers to an element, a DOM element, which is a convention in that library.
You can obtain the explanation seeing the source of the project in the 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.
It creates a tree of elements and appends them to body
el is a function that's been placed on the $ object, and can be invoked to generate DOM elements:
$.el('table')
el also acts as a placeholder for other objects, like the table function:
$.el.table()