使用jQuery mobile我正在创建一个简单的表单,显示可折叠的汽车品牌列表。在这个可折叠列表下将是汽车品牌的不同型号。当一个人点击/触摸汽车模型时,我希望能够加载到另一个页面,该页面将显示某个汽车模型的一些统计数据。我不太确定如何链接到另一个页面/ HTML文件。这就是我到目前为止所做的:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
a.test {
font-weight: bold;
}
</style>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- view port sets the bar as wide as the screen -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile- 1.3.2.min.css" />
<script src="jquery.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"> </script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Dream Ride</h1>
</div><!-- /header -->
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h1>Honda</h1>
//code to link to other HTML files or pages
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>BMW</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Mercedez</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Audi</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Ferrari</h3>
<p>sdfsdf</p>
</div>
<div data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u">
<h3>Lamborghini</h3>
<p>sdfsdf</p>
</div>
</div><!-- /content -->
<div data-role="footer">
<h4>My Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
答案 0 :(得分:1)
我假设你在谈论加载页面而不重新加载整个文档。要使用jQuery Mobile执行此操作,请创建另一个<div data-role="page">
并为其指定id属性。在您的第一页中,只需使用锚标记链接到它:<a href="#pageid"></a>
示例:
<div data-role="page" id="one">
<div data-role="content">
<h1>Page One</h1>
<a href="#two">Go to page two</a>
</div>
</div>
<div data-role="page" id="two">
<div data-role="content">
<h1>Page Two</h1>
<a href="#one">Go to page one</a>
</div>
</div>
JSFiddle的演示:http://jsfiddle.net/VaeCL/