jQuery Mobile Events


Events = the response actions of all different visitors when visiting the page.


jQuery Mobile Events

In jQuery Mobile, you can use any standardjQuery events 。

In addition, jQuery Mobile also provides events for mobile browsers:

  • Touch events - triggered when the user touches the screen
  • Swipe events - triggered when the user swipes up or down
  • Orientation events - triggered when the device is rotated horizontally or vertically
  • Page events - triggered when the page is shown, hidden, created, loaded, or fails to load

Initialize jQuery Mobile Events

When learning jQuery, we learned to use $(document).ready() to make your jQuery code scripts run only after the DOM elements have fully loaded:

jQuery document ready event

<script>
$(document).ready(function(){

   // write jQuery methods...

});
</script>

Try it yourself »

However, in jQuery Mobile, use the pageinit event to set code scripts to execute after the DOM elements have fully loaded, so to execute scripts when any new page is loaded and created, you need to bind the pageinit event.

The second parameter(#pageone) is the page id of the specified event:

jQuery Mobile pagecreate event

<script>
$(document).on("pagecreate","#pageone",function(){

   // jQuery event...

});
</script>

Try it yourself »

lamp  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.

Other Extensions