jQuery orientationchange Event

## jQ Mobile Tutorial

jQ Mobile HOME jQ Mobile Intro jQ Mobile Install jQ Mobile Pages jQ Mobile Transitions jQ Mobile Buttons jQ Mobile Icons jQ Mobile Toolbars jQ Mobile Navbars jQ Mobile Collapsibles jQ Mobile Grids

## jQ Mobile Lists

jQ Mobile List Views jQ Mobile List Content

## jQ Mobile Forms

jQ Mobile Form Basic jQ Mobile Form Inputs jQ Mobile Form Select jQ Mobile Form Sliders

## jQ Mobile Themes

jQ Mobile Themes

## jQ Mobile Events

jQ Mobile Events jQ Mobile Touch jQ Mobile Scroll jQ Mobile Orientation jQ Mobile Page Events

## Examples

jQ Mobile Examples

## References

jQ Data Attributes jQ Events jQ Icons

# jQuery orientationchange Event

jQuery Mobile Events

## Example

Alert some text when the user rotates the mobile device:

$(window).on("orientationchange",function(){
alert("The orientation has changed!");
});
Try it yourself »

## Definition and Usage

The orientationchange event is triggered when the user rotates the mobile device vertically or horizontally.

Note: To see the effect of the orientationchange event, the user must use a mobile device or a mobile emulator.

## Syntax

$(window).on("orientationchange",function(event){...})

Parameter | Description
--- | ---

function(event)

Required. Specifies the function to run when the orientationchange event occurs.

The function has an optional event object, which contains an orientation property equal to either "portrait" or "landscape".

- Portrait = device is held in a vertical position
- Landscape = device is held in a horizontal position

## Try it Yourself - Examples

The event object
Using the event.orientation to return the orientation of the mobile device.

The window object
Using the window.orientation property to set different styles between portrait and landscape views.

jQuery Mobile Events

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE