What Is ". El" in Relationship to Javascript/Html/jQuery?

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(
  $.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.

1

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.

1

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.