在Jquery 1.4.4中,您可以简单地使用:
<script>
$(function(){
$("[data-role='header'],[data-role='footer']").toolbar();
});
</script>
<script id="panel-init">
$(function(){
$( "[data-role='panel']").panel();
$( "[data-role='listview']").listview();
});
</script>
这适用于我的课堂移动网络项目,我的移动网络应用程序老师今天刚刚向我们展示了这一点。
在Jquery 移动 Web 应用程序中查看它
页面代码的其余部分是:
<div data-role="header" style="overflow-x:hidden;" data-position="fixed" data-theme="a">
<h1>Page One</h1>
<div data-role="controlgroup" data-type="horizontal" class="ui-mini ui-btn-left ui-icon-notext">
<a href="#nav-panel" class="ui-btn ui-btn-icon-right ui-icon-bars">Menu</a>
<a href="//soldierupdesigns.com/web295/jquery-mobile/" data-rel="back" data-ajax="false" class="ui-btn ui-btn-icon-right ui-icon-back">back</a>
</div>
<a href="#add-form" class="ui-btn-right ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-right ui-icon-gear">Add Form</a>
<div data-role="navbar">
<ul>
<li><a href="//soldierupdesigns.com/web295/jquery-mobile/" class="ui-btn-active">One</a></li>
<li><a href="#page2">Page Two</a></li>
<li><a href="#page3">Page Three</a></li>
<li><a href="#page4">Page Four</a></li>
<li><a href="#page5">Page Five</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
<div data-role="panel" data-display="overlay" data-theme="b" id="nav-panel" data-inset="false" data-position-fixed="true">
<ul data-role="listview" data-theme="b">
<li class="list-group-item active" data-icon="delete"><a href="#" data-rel="close" style="color:#ffffff;">Close menu</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Accordion</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Ajax Navigation</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Autocomplete</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Buttons</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Checkboxes</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Collapsibles</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Controlgroup</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Dialogs</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Fixed toolbars</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Flip switch toggle</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Footer toolbar</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Form elements</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Grids</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Header toolbar</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Icons</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Links</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Listviews</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Loader overlay</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Navbar</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Navbar, persistent</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Pages</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">New</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Popup</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Radio buttons</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Select</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Slider, single</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">New</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">New</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">New</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Text inputs & textarea</a></li>
<li class="list-group-item"><a href="#panel-responsive-page2">Transitions</a></li>
</ul>
</div><!-- /panel -->
<div data-role="panel" data-position="right" data-display="reveal" data-theme="a" id="add-form">
<form class="userform">
<h2>Login</h2>
<label for="name">Username:</label>
<input type="text" name="name" id="name" value="" data-clear-btn="true" data-mini="true">
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="" data-clear-btn="true" autocomplete="off" data-mini="true">
<div class="ui-grid-a">
<div class="ui-block-a"><a href="#" data-rel="close" class="ui-btn ui-shadow ui-corner-all ui-btn-b ui-mini">Cancel</a></div>
<div class="ui-block-b"><a href="#" data-rel="close" class="ui-btn ui-shadow ui-corner-all ui-btn-a ui-mini">Save</a></div>
</div>
</form>
</div><!-- /panel -->
<div data-role="page" class="ui-responsive-panel" id="panel-responsive-page1" data-title="Panel responsive page">
<div class="ui-content"></div>
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>Panel responsive</h1>
<p>This is a typical page that has two buttons in the header bar that open panels. The left panel has the push display mode, the right panel reveal. To make this responsive, you can make the page re-flow at wider widths. This allows both the panel menu and page to be used together when more space is available. This behavior is controlled by CSS media queries. You can create a custom one for a specific breakpoint or use the breakpoint preset by adding the <code>class="ui-responsive-panel"</code> to the page container. We have added this class on this demo page. Note that when using the preset class, we also hide the dismiss layer on wider screens if the panel has the push display mode.</p>
<div data-demo-html="#panel-responsive-page1" data-ajax="true" >View Source</div><!--/demo-html -->
<br>
<br>
<br>
<br>
<br>
<a href="#panel-responsive-page1" data-rel="back" data-ajax="false" class="ui-btn ui-shadow ui-corner-all ui-mini ui-btn-inline ui-icon-carat-l ui-btn-icon-left ui-alt-icon ui-nodisc-icon">back</a>
</div><!-- /content -->
</div><!-- /page -->
<div data-role="footer" style="overflow:hidden;" data-position="fixed" data-tap-toggle="false" class="jqm-footer" data-theme="a">
<div data-role="navbar">
<ul>
<li><a href="//soldierupdesigns.com/web295/jquery-mobile/" class="ui-btn-active">One</a></li>
<li><a href="#page2">Page Two</a></li>
<li><a href="#page3">Page Three</a></li>
<li><a href="#page4">Page Four</a></li>
<li><a href="#page5">Page Five</a></li>
</ul>
</div><!-- /navbar -->
<p>Copyright 2014 The jQuery Foundation</p>
<p>jQuery Mobile Demos version <span class="jqm-version"></span></p>
</div><!-- /footer -->
<div data-role="page" id="panel-responsive-page2">
<div data-role="header">
<h1>Landing page</h1>
</div><!-- /header -->
<div role="main" class="ui-content jqm-content">
<p>This is just a landing page.</p>
<a href="#panel-responsive-page1" data-rel="back" data-ajax="false" class="ui-btn ui-btn-icon-right ui-icon-back">back</a>
</div><!-- /content -->
</div><!-- /page -->
<div data-role="page" class="jqm-demos ui-responsive-panel" id="page2" data-title="Panel responsive page">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>Page 2</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pretium pretium nisi in semper. Integer lectus nibh, fermentum rutrum sagittis vel, sagittis in sem. Praesent condimentum, orci vitae dapibus laoreet, augue odio luctus arcu, eget ultrices lacus ligula non mi. Mauris aliquam et ligula vel mollis. Curabitur pulvinar quis augue id tempus. Phasellus rutrum rhoncus mauris, vel tincidunt sapien porttitor eget. Vivamus sagittis lacus non felis rhoncus, sed feugiat odio ornare. Praesent at sapien vel dolor gravida imperdiet. Nulla mi felis, elementum eget sapien ac, cursus lobortis risus. Aliquam in lacus in arcu placerat laoreet et quis nulla. Morbi et nunc ultricies, molestie augue a, tempor ipsum. Vestibulum non mi mattis, dapibus magna non, condimentum risus. Nam fermentum, ligula ultrices rhoncus vestibulum, augue diam feugiat elit, vitae tincidunt urna odio at erat. Maecenas in mattis libero.</p>
<p>Sed pulvinar nibh nulla, vitae dapibus odio faucibus id. Curabitur rutrum sodales dolor. Suspendisse mattis semper dapibus. Nullam iaculis tristique orci, ut consectetur augue accumsan eget. Duis turpis massa, egestas at lobortis nec, mollis eget sapien. Aliquam sed blandit lacus, ac fringilla nunc. Praesent quis faucibus magna, a imperdiet nulla. Pellentesque tristique, elit ut cursus tristique, ex turpis placerat dolor, non vehicula sem urna a nibh. In tristique hendrerit ex nec rutrum. Aenean sodales erat nisl, sed consequat enim consectetur id. Vivamus sit amet suscipit quam, a efficitur ante. Integer in luctus diam. Integer fringilla felis risus, vitae vehicula quam pharetra vel. Maecenas ligula lacus, lobortis a condimentum sit amet, faucibus sit amet nisi. Donec mattis scelerisque fringilla.</p>
</div>
</div><!-- /page2 -->
<div data-role="page" class="jqm-demos ui-responsive-panel" id="page3" data-title="Panel responsive page">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>Page 3</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pretium pretium nisi in semper. Integer lectus nibh, fermentum rutrum sagittis vel, sagittis in sem. Praesent condimentum, orci vitae dapibus laoreet, augue odio luctus arcu, eget ultrices lacus ligula non mi. Mauris aliquam et ligula vel mollis. Curabitur pulvinar quis augue id tempus. Phasellus rutrum rhoncus mauris, vel tincidunt sapien porttitor eget. Vivamus sagittis lacus non felis rhoncus, sed feugiat odio ornare. Praesent at sapien vel dolor gravida imperdiet. Nulla mi felis, elementum eget sapien ac, cursus lobortis risus. Aliquam in lacus in arcu placerat laoreet et quis nulla. Morbi et nunc ultricies, molestie augue a, tempor ipsum. Vestibulum non mi mattis, dapibus magna non, condimentum risus. Nam fermentum, ligula ultrices rhoncus vestibulum, augue diam feugiat elit, vitae tincidunt urna odio at erat. Maecenas in mattis libero.</p>
<p>Sed pulvinar nibh nulla, vitae dapibus odio faucibus id. Curabitur rutrum sodales dolor. Suspendisse mattis semper dapibus. Nullam iaculis tristique orci, ut consectetur augue accumsan eget. Duis turpis massa, egestas at lobortis nec, mollis eget sapien. Aliquam sed blandit lacus, ac fringilla nunc. Praesent quis faucibus magna, a imperdiet nulla. Pellentesque tristique, elit ut cursus tristique, ex turpis placerat dolor, non vehicula sem urna a nibh. In tristique hendrerit ex nec rutrum. Aenean sodales erat nisl, sed consequat enim consectetur id. Vivamus sit amet suscipit quam, a efficitur ante. Integer in luctus diam. Integer fringilla felis risus, vitae vehicula quam pharetra vel. Maecenas ligula lacus, lobortis a condimentum sit amet, faucibus sit amet nisi. Donec mattis scelerisque fringilla.</p>
</div>
</div><!-- /page3 -->
<div data-role="page" class="jqm-demos ui-responsive-panel" id="page4" data-title="Panel responsive page">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>Page 4</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pretium pretium nisi in semper. Integer lectus nibh, fermentum rutrum sagittis vel, sagittis in sem. Praesent condimentum, orci vitae dapibus laoreet, augue odio luctus arcu, eget ultrices lacus ligula non mi. Mauris aliquam et ligula vel mollis. Curabitur pulvinar quis augue id tempus. Phasellus rutrum rhoncus mauris, vel tincidunt sapien porttitor eget. Vivamus sagittis lacus non felis rhoncus, sed feugiat odio ornare. Praesent at sapien vel dolor gravida imperdiet. Nulla mi felis, elementum eget sapien ac, cursus lobortis risus. Aliquam in lacus in arcu placerat laoreet et quis nulla. Morbi et nunc ultricies, molestie augue a, tempor ipsum. Vestibulum non mi mattis, dapibus magna non, condimentum risus. Nam fermentum, ligula ultrices rhoncus vestibulum, augue diam feugiat elit, vitae tincidunt urna odio at erat. Maecenas in mattis libero.</p>
<p>Sed pulvinar nibh nulla, vitae dapibus odio faucibus id. Curabitur rutrum sodales dolor. Suspendisse mattis semper dapibus. Nullam iaculis tristique orci, ut consectetur augue accumsan eget. Duis turpis massa, egestas at lobortis nec, mollis eget sapien. Aliquam sed blandit lacus, ac fringilla nunc. Praesent quis faucibus magna, a imperdiet nulla. Pellentesque tristique, elit ut cursus tristique, ex turpis placerat dolor, non vehicula sem urna a nibh. In tristique hendrerit ex nec rutrum. Aenean sodales erat nisl, sed consequat enim consectetur id. Vivamus sit amet suscipit quam, a efficitur ante. Integer in luctus diam. Integer fringilla felis risus, vitae vehicula quam pharetra vel. Maecenas ligula lacus, lobortis a condimentum sit amet, faucibus sit amet nisi. Donec mattis scelerisque fringilla.</p>
</div>
</div><!-- /page4 -->
<div data-role="page" class="jqm-demos ui-responsive-panel" id="page5" data-title="Panel responsive page">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<h1>Page 5</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pretium pretium nisi in semper. Integer lectus nibh, fermentum rutrum sagittis vel, sagittis in sem. Praesent condimentum, orci vitae dapibus laoreet, augue odio luctus arcu, eget ultrices lacus ligula non mi. Mauris aliquam et ligula vel mollis. Curabitur pulvinar quis augue id tempus. Phasellus rutrum rhoncus mauris, vel tincidunt sapien porttitor eget. Vivamus sagittis lacus non felis rhoncus, sed feugiat odio ornare. Praesent at sapien vel dolor gravida imperdiet. Nulla mi felis, elementum eget sapien ac, cursus lobortis risus. Aliquam in lacus in arcu placerat laoreet et quis nulla. Morbi et nunc ultricies, molestie augue a, tempor ipsum. Vestibulum non mi mattis, dapibus magna non, condimentum risus. Nam fermentum, ligula ultrices rhoncus vestibulum, augue diam feugiat elit, vitae tincidunt urna odio at erat. Maecenas in mattis libero.</p>
<p>Sed pulvinar nibh nulla, vitae dapibus odio faucibus id. Curabitur rutrum sodales dolor. Suspendisse mattis semper dapibus. Nullam iaculis tristique orci, ut consectetur augue accumsan eget. Duis turpis massa, egestas at lobortis nec, mollis eget sapien. Aliquam sed blandit lacus, ac fringilla nunc. Praesent quis faucibus magna, a imperdiet nulla. Pellentesque tristique, elit ut cursus tristique, ex turpis placerat dolor, non vehicula sem urna a nibh. In tristique hendrerit ex nec rutrum. Aenean sodales erat nisl, sed consequat enim consectetur id. Vivamus sit amet suscipit quam, a efficitur ante. Integer in luctus diam. Integer fringilla felis risus, vitae vehicula quam pharetra vel. Maecenas ligula lacus, lobortis a condimentum sit amet, faucibus sit amet nisi. Donec mattis scelerisque fringilla.</p>
</div>
</div><!-- /page5 -->