Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Last active August 30, 2024 15:27
Show Gist options
  • Save juanbrujo/a1f77db1e6f7cb17b42b to your computer and use it in GitHub Desktop.
Save juanbrujo/a1f77db1e6f7cb17b42b to your computer and use it in GitHub Desktop.
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);
}
}
/*
Use:
var input = document.querySelector('input');
multipleEventsListeners(input, 'keyup change', function(e){
console.log(this.value);
});
*/
@ludreykimm
Copy link

With this tool Bloxstrap open-source, users can safely add fonts, modify textures, and change typefaces without any risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment