Click here to Skip to main content
15,887,850 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
I tried

    $('#page18').bind("load",function() {
            alert("total Type") ;
        });

    and also i tried doing this

    $('#page18').ready( function() {
            alert("total Type")

I want to call a function on Load of a Html5 Jquery Mobile page.

    I have various Div with <data-role="page">
    Each of them has Id.Now with navigation when I reach on <div id="page18"> i want to cal a function ...
        });

    But cant seem to fig it out. can anyone help me with this
Posted

1 solution

A load when the document is loaded/ready
JavaScript
$(document).ready(function() {
   // ...
});

which is equal to
JavaScript
$(function() {
   // ...
});


A load each time an element with data-role="page" is showed:

C#
$('[data-role=page]').on('pageshow', function (event, ui) {
   // ...
});


When a specific data-page is shown:

C#
$('#page18').on('pageshow', function (event, ui) {
   // ...
});


Requires jQuery 1.7 or higher (the .on method was added in version 1.7)
 
Share this answer
 
v2
Comments
gaurish thakkar 17-Aug-12 6:59am    
Thank U very very much....:)
gaurish thakkar 17-Aug-12 8:48am    
Can u plz tell me how can i detect if an input tag exits in the Div.
StianSandberg 17-Aug-12 9:59am    
jquery has a lot of selectors to find html elements. jQuery Selectors
gaurish thakkar 21-Aug-12 8:15am    
i got it ..thnx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900