Monday, December 12, 2011

Create collapsible block in jQuery Mobile

To create a collapsible block of content, create a container and add the data-role="collapsible" attribute.

example:
Collapsible Block

<!DOCTYPE html>
<html>
<head>
<title>Basic jQuery Mobile Web Page</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
</head>
<body>

<div data-role="page" id="home">
<div data-role="header">
<h1>mobile-web-app</h1>
</div>
<div data-role="content">
<p>Collapsible Block</p>
<div data-role="collapsible">
<H1>To create a collapsible block </H1>
<p>create a container and add the data-role="collapsible" attribute.</p>
</div>
<div data-role="collapsible">
<H2>Only the first h-element will be processed as header!</H2>
<H2>So, it's normal heading text!</H2>
<p>Content of Collapsible Block 2</p>
</div>
<div data-role="collapsible">
<p>You can place h-element in any where within Collapsible Block</p>
<H3>You can place h-element in any where within Collapsible Block</H3>
</div>
<div data-role="collapsible" data-collapsed="false">
<H3>Defult expanded Collapsible Block</H3>
<p>add the data-collapsed="false" attribute</p>
</div>
</div>
<div data-role="footer">
<h4><a href="http://mobile-web-app.blogspot.com/">http://mobile-web-app.blogspot.com/</a></h4>
</div>
</div>

</body>
</html>


Related article:
- Nested Collapsible Block
- Collapsible Set

No comments:

Post a Comment