Event delegation

This entire page is clickable (touchable). But on iOS the mouse events don’t always bubble up to the document.

Instead, iOS needs an event handler, which may be an empty function, to be set on any descendant of the body, but not the body itself or the document. If such an event handler is set the events bubble up.

Exceptions: events whose target is a link or a form field always bubble up.

You can set the events on the document, the body, or the wrapper div that wraps the entire page. On iOS, only the last option causes all events to bubble up.

Try this link.

Try this paragraph with a tabindex. The point of this test is that elements with tabindex can traditionally receive clicks.

Try this paragraph, which has nothing special.

Try this paragraph, which has an empty on event handler.