YouTip LogoYouTip

Event Orientationchange

# jQuery Mobile orientationchange Event [![Image 4: jQuery Mobile Events](#) jQuery Mobile Events](#) ## Example Display some text when the user flips the mobile device: ```javascript $(window).on("orientationchange",function(){ alert("Orientation has changed!"); }); [Try it Yourself Β»](#) * * * ## Definition and Usage The `orientationchange` event is triggered when the user flips the device horizontally or vertically (i.e., when the orientation changes). **Note:** To see the effect of the `orientationchange` event, the user must use a mobile device or a mobile simulator to view the examples on this site. * * * ## Syntax ```javascript $(window).on("orientationchange",function(event){...}) | Parameter | Description | | --- | --- | | function(event) | Required. Specifies the function to run after the `orientationchange` event is triggered. To determine which direction the device is rotated, you can access the `orientation` property. The property value can be "portrait" or "landscape".
* Portrait = Device is rotated to a vertical position
* Landscape = Device is rotated to a horizontal position | * * * ![Image 5: Examples](#) ## More Examples (#) Use `event.orientation` to return the orientation of the mobile device. (#) Use the `window.orientation` property to set different styles for "portrait" and "landscape". * * jQuery Mobile Events](#)
← Event PagebeforecreateJquerymobile Ref Events β†’