Recently, I've asked a question about how to create a shortand for addEventListener, the result was:
var dom = {
id: function(elementId) {
var element = document.getElementById(elementId);
return Object.create(element, {
on: {
value(event, fn, options) {
element.addEventListener(event, fn, options);
}
}
})
}
};
what if I wanted to add two Object.create? How would I return it? Is it even possible?
id="el"and dodom.id("el").on("click", doThis());, it firesdoThis()immediately and the click event isn't attached. Can you add the code showing its implementation?dom.id('el').on('click', function() { this.innerText = 'text' });doThis()it will fire function. PassdoThiswithout().