Footer configuration

Footer bar structure

The footer bar has the same structure as the header except for the data-role attribute and your choice of heading. Footers tend to be more freeform than headers in terms of content and functionality but they are designed to hold text and buttons, just like a header.

<div data-role="footer"> 
	<h4>Footer content</h4> 
</div> 

The page footer is very similar to the header in terms of options and configuration. The primary differences are that the footer is designed to be less structured than the header to allow for more flexibility, so the framework doesn't automatically place buttons to the left or right based on source order as it does in the header. A footer is identified with the data-role="footer attribute and can contain any markup.

<div data-role="footer"> 
   ...
</div> 

Theming options

Both the header and footer bars will be styled by default with the theme's "a" color swatch (black in the default theme) because these bars are typically primary in the visual hierarchy of a page. To set the header or footer bars to a different color in your theme, add the data-theme attribute and specify the letter of the theme swatch (a, b, c, etc.). For example, this will set the bar to swatch "b" (blue in the default theme):

<div data-role="header" data-theme="b"> 
	<h4>Footer content goes here</h4> 
</div> 

One common scenario is to have a few buttons in the footer. Just like the header, adding a set of anchor links inside the footer bar will trigger the mobilize() function to transform the links into the styled mobile buttons. In the footer, each button will be as wide as the text and icon contents and the buttons will sit side-by-side because each has the CSS display:inline-block property.

<div data-role="footer"> 
	<a href="index.html" data-icon="plus">New</a> 
	<a href="index.html" data-icon="delete">Delete</a> 
	<a href="index.html" data-icon="search">Search</a> 
</div> 

Persistent footers

In situations where the footer is being used as a global navigation element, you may want the footer to appear like it is fixed in place between page transitions. This can be accomplished by using the persistent footer feature included in jQuery Mobile. To make a footer appear to stay in place between transitions, simply add the data-id attribute to the footer of both pages and use the same id value for each. For example, by adding data-id="myfooter" to the current page and the target page, the framework will keep the footer anchors in the same spot during the page animation. This effect will only work correctly if the header and footer toolbars are set to sticky so they are in view during the transition.

If you want the footer to appear persistent as you navigate between pages (especially useful if using a nav bar, see below), you can achieve this effect by adding a data-id attribute to each page that should have the persistent footer. Giving a set of pages the same data-id attribute value (like "foo"), tells the framework to use the persistent footer transition when animating.

Persistent footer example