HTML5 Mobile web Application Development-JQuery Mobile (4)-Events

Source: Internet
Author: User

HTML5 Mobile web Application Development-JQuery Mobile (4)-Events

Jquery Mobile provides a wide range of event processing and detection mechanisms.

1. Rolling events

In Jquery Mobile, scrollStart and scrollStop events are used to listen to events where users start and stop scrolling. The following code uses scrollStart as an example:

$ (Document). on ("scrollstart", function () {alert ("start rolling! ");});
2. Interface related events

From activation to loading, a page is divided into four parts in jquery mobile:

Page Initialization-before the Page is created, when the Page is created, and after the Page is initialized

Page Load/Unload-when an external Page is loaded, uninstalled, or failed

Page Transition-before and after Page Transition

Page Change-when the Page is changed or fails

In the page initialization section, jquery mobile divides it into three stages: pagebeforecreate, pagecreate, and pageinit, you can execute corresponding actions in each stage. The sample code is as follows:
$(document).on("pagebeforecreate",function(event){  alert(" pagebeforecreate ");}); $(document).on("pagecreate",function(event){  alert(" pagecreate ");});$(document).on("pageinit",function(event){  alert(" pageinit ")});
3. About device direction

The following is the sample code from w3cschool. You can listen to the changes in the device direction and set different styles after the changes in the device direction;

$(window).on("orientationchange",function(){  if(window.orientation == 0) // Portrait  {    $("p").css({"background-color":"yellow","font-size":"300%"});  }  else // Landscape  {    $("p").css({"background-color":"pink","font-size":"200%"});  }});

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.