jQuery Mobile Events
Events = the response actions to all the different ways visitors access a page.
jQuery Mobile Events
In jQuery Mobile you can use any standard jQuery events 。
In addition, jQuery Mobile also provides events for mobile browsers:
- Touch events - triggered when a user touches the screen
- Swipe events - triggered when a user swipes up or down
- Orientation events - triggered when a device is flipped horizontally or vertically
- Page events - triggered when a page is shown, hidden, created, loaded, or unloaded
Initialize jQuery Mobile Events
When learning jQuery we learned to use $(document).ready() to make your jQuery code start executing only after the DOM elements have loaded:
jQuery document ready Event
Try it »
However, in jQuery Mobile, the pageinit event is used to set code to start executing after DOM elements have loaded, so to execute scripts when any new page is loaded and created, you need to bind the pageinit event.
The second parameter ("#pageone") specifies the id of the page for the event:
jQuery Mobile pagecreate event
Try it »
![]() |
Note: The jQuery on() method is used to bind events to selected elements. |
|---|
In the next chapter we will introduce jQuery Mobile events in more detail.
