Nodejs HTML Element Event Add addEvent(event, callback, bubble)

Here you can find the source of addEvent(event, callback, bubble)

Method Source Code

HTMLElement.prototype.addEvent = function (event, callback, bubble) {
    this.addEventListener(/*from  w  ww  . j  ava  2s  .  com*/
        event,
        function (event) {
            try {
                callback.apply(this, arguments);
            } catch (e) {
                console.log(e);
            }
            event.preventDefault();
            return false;
        },
        bubble);
};

Related

  1. addClickEvent(func)
    HTMLElement.prototype.addClickEvent = function addClickEvent(func) {
        this.addEvent("click", func, false);
    };
    
  2. delegate(eventName, elementSelector, cb)
    Element.prototype.delegate = function(eventName, elementSelector, cb) {
      var _this = this
      _this.addEventListener(eventName, function(evt) {
        var _this = evt.target
        if (_this.is(elementSelector)) {
          cb.call(_this, evt)
        if (_this.parentNode.is(elementSelector)) {
          cb.call(_this.parentNode, evt)
    ...