Evento is a simple and easy library to works with javascript events.
You can add a custom events or the DOM events like click, mouseover, etc.
bower install eventojs
Or just add the evento.js
in the HTML file.
<script src="evento.js"></script>
Just use Evento.applyTo
for simple objects or Evento.applyToHtml
for DOM elements.
var person = {
name: Gustavo
};
Evento.applyTo(person);
person.bind('say', function (message) {
console.log(message);
});
person.trigger('say', 'hello!');
var button = document.querySelector('#myButton');
Evento.applyTo(button);
button.bind('click', function () {
console.log('Hello!!!');
});
button.trigger('click');
Binds a function on event
Runs the function added by bind
Removes the hide
class
Adds the hide
class that contains display:none
Adds a css class
Removes a css class
MIT