Edit this page

up.event up.$on([element], events, [selector], [options], listener)
JavaScript function

This feature has been deprecated. Use up.on() with a callback that wraps the given native element in a jQuery collection.

Load unpoly-migrate.js to polyfill deprecated features.

Listens to an event on document or a given element. The event handler is called with the event target as a jQuery collection.

If you're not using jQuery, use up.on() instead, which calls event handlers with a native element.


up.$on('click', 'a', function(event, $link) {
  console.log("Click on a link with destination %s", $element.attr('href'))


[element=document] ElementorjQuery optional

The element on which to register the event listener.

If no element is given, the listener is registered on the document.

events string

A space-separated list of event names to bind to.

[selector] string optional

The selector of an element on which the event must be triggered. Omit the selector to listen to all events with that name, regardless of the event target.

[options.passive=false] boolean optional

Whether to register a passive event listener.

A passive event listener may not call event.preventDefault(). This in particular may improve the frame rate when registering touchstart and touchmove events.

listener Function(event, [element], [data])

The listener function that should be called.

The function takes the observed element as the first argument. The element's attached data is passed as a third argument.

Return value


A function that unbinds the event listeners when called.