13 lines
465 B
JavaScript
13 lines
465 B
JavaScript
var actions = [ 'change', 'click', 'dblclick', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'scroll', 'blur', 'focus', 'input', 'submit', 'keydown', 'keypress', 'keyup' ]
|
|
|
|
function event(id, fn) {
|
|
// Find all classes ending in the event id
|
|
actions.forEach(function(action) {
|
|
$('*[on-' + action + '="' + id + '"]').each(function() {
|
|
if(this.getAttribute('on-' + action).indexOf(id) !== -1)
|
|
$(this).on(action, fn)
|
|
})
|
|
})
|
|
}
|
|
|
|
module.exports = event
|