jquery mobile 使用button标签跳转界面
时间: 2023-09-17 21:11:09 浏览: 59
要在 jQuery Mobile 中使用 button 标签跳转界面,可以使用 data 属性来定义要跳转到的页面。以下是一个示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Button 跳转界面示例</title>
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>首页</h1>
</div>
<div data-role="content">
<a href="#page2" data-role="button">跳转到页面 2</a>
</div>
<div data-role="footer">
<h4>页脚</h4>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="header">
<h1>页面 2</h1>
</div>
<div data-role="content">
<a href="#page1" data-role="button">返回首页</a>
</div>
<div data-role="footer">
<h4>页脚</h4>
</div>
</div>
</body>
</html>
```
在这个示例中,我们使用了 `data-role="button"` 来定义按钮样式,并且使用 `href` 属性来指定要跳转到的页面。跳转到的页面需要使用一个唯一的 `id`,并将其指定为 `a` 元素的 `href` 值。
请注意,以上示例中引用的 jQuery Mobile 库文件的版本号是 1.4.5,你可以根据需要使用最新版本的库文件。