Skip to content

Instantly share code, notes, and snippets.

View juanjosezg's full-sized avatar
💻

Juan José Zermeño juanjosezg

💻
View GitHub Profile
@juanjosezg
juanjosezg / multipleEventsListeners.js
Created February 22, 2019 18:15 — forked from juanbrujo/multipleEventsListeners.js
Add the capability to attach multiple events to an element, just like jQuery does
/**
* multipleEventsListeners.js
* Add the capability to attach multiple events to an element, just like jQuery does
* https://gist.github.com/juanbrujo/a1f77db1e6f7cb17b42b
*/
function multipleEventsListeners(elem, events, func) {
var event = events.split(' ');
for (var i = 0; i < event.length; i++) {
elem.addEventListener(event[i], func, false);