How to create shortand for addEventListener

I want to create a shortand for addEventListener, the code I’m trying is:

var dom = {
  id: function(elementId) {
    return document.getElementById(elementId);
}; = function(event, options) {
  var id = id.elementId;
  return id.addEventListener(event, function() {

When I use it like that:'paragraph').on('click','paragraph').innerText = 'clicked');

It instantly changes it’s innerText to clicked, without I even clicking it.

11 thoughts on “How to create shortand for addEventListener”

Leave a Comment