跳到主要内容

trigger

trigger(event, [args]) ⇒ self

Trigger the specified event on elements of the collection. Event can either be a string type, or a full event object obtained with $.Event. If an args array is given, it is passed as additional arguments to event handlers.

// add a handler for a custom event
$(document).on('mylib:change', function(e, from, to){
console.log('change on %o with data %s, %s', e.target, from, to)
})
// trigger the custom event
$(document.body).trigger('mylib:change', ['one', 'two'])

Zepto only supports triggering events on DOM elements.