I have been learning DOM recently, but found that the API of DOM is really long and hard to remember. This article is encapsulated in object style. I’ll write another jQuery wrapper later

What is encapsulation

For example,

  • Computer notebook is CPU memory hard disk motherboard display card packaging
  • Users only need to touch the monitor, keyboard, mouse, touch pad and other devices
  • Can operate complex computers

What is an interface

  • Something encapsulated needs to expose some functionality to the outside world
  • These functions are interfaces, such as USB interfaces and HDMI interfaces
  • The device only needs to support these interfaces in order to interact with the encapsulated thing
  • For example, the keyboard and mouse support USB interface and the monitor support HDMI interface

The same goes for wrapping the DOM:

2. Some DOM terms (depending on personal use)

1. The library

  • We call the tool code that we make available to others a library

Example: jQuery, Underscore

2.API

  • The functions or properties that the library exposes are called apis

3. The framework

  • When your library gets big and you have to learn to understand it,

So this library is called a framework, like Vue/React

4. Pay attention to

  • Most of the programming language is very informal and has no fixed interpretation

So just be spontaneous

Three. Not to say directly on the code, there is a detailed explanation.

  • Code link github.com/Logansheng/…
  • If you have any questions, I’ll get back to you