0

我正在使用 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>
4

1 回答 1

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/

于 2013-09-05T19:09:03.283 回答