监听某个 DOM 的节点变化

MutationObserver
https://www.yuque.com/sylaryip/aasla4/coaotc/edit
点击查看【codepen】

自定义事件

  1. Element.prototype.bindEvent = function (eventName, callback) {
  2. var _event = new Event(eventName),
  3. _ele = this;
  4. _ele.addEventListener(eventName, callback, false);
  5. return {
  6. dispatch: function () {
  7. _ele.dispatchEvent(_event);
  8. },
  9. remove: function () {
  10. _ele.removeEventListener(eventName, callback, false);
  11. },
  12. };
  13. };

获取某节点下所有的标签及其出现次数

点击查看【codepen】

DOM0 DOM2 DOM3 DOM4

https://www.yuque.com/sylaryip/aasla4

什么是标签?什么是元素?

标签


元素
123

DOM 对象、DOM 元素、DOM 节点是同一样东西吗?

都是指同一样东西,只是对其角度不一样而已。

对象 Object 数据 DOM 节点对应节点的数据,用来描述 DOM
元素 Element HTML
123
转为 JS DOM
节点 Node DOM 树 DOM 对象

节点 : 对象

  1. {
  2. Node : Object
  3. }