Skip to main content

jQuery Mobile page transitions simple demo

jQuery Mobile has amazing Ajax page transitions available by default. This blog post gives a quick example to demonstrate the same.

Click here to launch the below code in a separate browser.

<!DOCTYPE html>
    <title>Transitions Demo</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet"
href="" />
<script src=""></script> <script src=""></script>
    <div id="page1" data-role="page">
      <div data-role="header">
        <h1>Pick your transition</h1>
      <div data-role="content">
        <p><a href="#page2" data-role="button" data-transition="slide">Slide</a></p>
        <p><a href="#page2" data-role="button" data-transition="slideup">Slideup</a></p>
        <p><a href="#page2" data-role="button" data-transition="slidedown">Slidedown</a></p>
        <p><a href="#page2" data-role="button" data-transition="pop">Pop</a></p>
        <p><a href="#page2" data-role="button" data-transition="fade">Fade</a></p>
        <p><a href="#page2" data-role="button" data-transition="flip">Flip</a></p>
    <div id="page2" data-role="page">
      <div data-role="header">
        <h1>Reverse the transition now</h1>
      <div data-role="content">
<p><a href="#" data-role="button" data-rel="back" 

So there are 6 page transitions are available by default and the data-transition attribute specifies the same.
  1. Slide
  2. Slideup
  3. Slidedown
  4. Pop (best for dialogs)
  5. Fade
  6. Flip
I've also included an option to reverse the most recent page transition and this is done using the data-rel and data-direction attribute as shown. As shown in the docs, adding a data-rel="dialog" attribute to the anchor link will open the page as a dialog.

Simple isn't it. Enjoy !!


  1. Hi Chetan, thanks a lot for this useful example. I just started playing with jQuery Mobile. I noticed that if I try to use the new version (right now, the 1.4.5) it does not work. Any idea about why? Thanks a lot


Post a Comment

Popular posts from this blog

Minimal required code in HTML5

I've encountered this question repeatedly of late. "What are the tags required at bare minimum for a html file?" Earlier there were a bunch of mandatory tags that were required for any html file. At bare minimum, the recommended structure was: (ref: ) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ""> <HTML>   <HEAD>     <TITLE>A small HTML</TITLE>   </HEAD>   <BODY>     <P>Small HTML file!</P>   </BODY> </HTML> Yes, using capitals for the tags was the way to go! Those were the days of the purists and strict was the way to be. Now open your notepad and copy the above code, save the file as old.html and launch it in Chrome or Firefox. You will see only one line "Small HTML file!" shown. Now launch the developer tools in Chrome or Inspect Element in Firefox. Thi

Using duplicate IDs in HTML

Well today I'm being a bit controversial. Let us see what the HTML5 spec says about unique IDs in a HTML file. The  id  attribute specifies its element's  unique identifier (ID) . The value must be unique amongst all the IDs in the element's  home subtree  and must contain at least one character. The value must not contain any  space characters . An element's  unique identifier  can be used for a variety of purposes, most notably as a way to link to specific parts of a document using fragment identifiers, as a way to target an element when scripting, and as a way to style a specific element from CSS. Yes its been mentioned almost everywhere on the planet that ID must be unique. Now let us look at the below code, Launch dup.css #p2 {   background-color: yellow;  } dup-id.html <!DOCTYPE html> <html>   <head>     <title>Duplicate ID Tester</title> <link rel="stylesheet" href="dup.css" />  

Fixing Date, Time and Zone on RHEL 6 command line

Had to fix all time related issues on a remote RHEL 6 server which runs without any windowing system. Plain ol' command line. Documenting steps here for future reference: Check to see if your date and timezone settings are accurate: # date # cat /etc/sysconfig/clock The server I accessed had wrong settings for both the commands. Here are the steps I used to correct: Find out your timezone from the folder /usr/share/zoneinfo # ls /usr/share/zoneinfo Mine was pointing to America/EDT instead of  Asia/Calcutta Update and save the /etc/sysconfig/clock file to # sudo vi /etc/sysconfig/clock ZONE="Asia/Calcutta" UTC=true ARC=false Remove the /etc/localtime # sudo rm /etc/localtime Create a new soft link to your time zone # cd /etc # sudo ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime # ls -al localtime Now it should show the link to your time zone Set your hardware clock to UTC # sudo hwclock --systohc --utc # hwclock --show Update your t