Event Pageinit
# jQuery Mobile pageinit Event
[ jQuery Mobile Events](#)
## Example
Alert a message when the page is initialized and enhanced:
```javascript
$(document).on("pageinit",function(){
alert("pageinit event triggered!")
});
[Try it Yourself Β»](#)
* * *
## Definition and Usage
This event is deprecated since version 1.4.0, use (#) instead.
The pageinit event is triggered after the page is initialized and jQuery Mobile has finished enhancing the page content.
Use this event instead of the jQuery DOM ready event, because it will trigger regardless of whether the page is loaded directly or via an Ajax call.
**Note:** This event can only be triggered once per page - when the page is loaded for the first time, jQuery Mobile caches the page in the DOM (memory), so when you navigate back to the first page from the second page using the browser, this event will not be triggered, because the first page has already been initialized.
**Related Events:**
- Triggered before page initialization and before jQuery Mobile starts enhancing the page.
- Triggered after the page is created successfully, but before the page enhancement is complete.
* * *
## Syntax
To trigger all page events in jQuery Mobile:
```javascript
$("document").on("pageinit",function(event){...})
(#)
To trigger a specific page event:
```javascript
$("document").on("pageinit","_page_",function(event){...})
(#)
| Parameter | Description |
| --- | --- |
| function(event) | Required. The function to execute after the pageinit event is triggered. The function is an optional event object containing any jQuery event properties (e.g., event.target, event.type, etc.). See the (#) for more jQuery event properties. |
| _page_ | Optional. Used to specify the page ID for which the pagebeforecreate event is triggered. For internal pages, use _#id_. For external pages, use _externalfile.html_. |
* * *

## More Examples
[Demonstration of pagebeforecreate and pagecreate events.](#)
This example demonstrates the triggering of pagebeforecreate and pagecreate events.
(#)
Use the event.type property to return the type of event triggered.
* * jQuery Mobile Events](#)
YouTip