jQuery Mobile 安装学习笔记
安装
- 在 jQuery Mobile 官网 上下载最新版的 jQuery Mobile。
- 将下载的文件解压缩到项目文件夹中。
- 在 HTML 文件中引入 jQuery 和 jQuery Mobile 文件。
htmlCopy Code<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Installation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
实例
以下是一个简单的 jQuery Mobile 实例,展示了一个带有标题和按钮的页面。
htmlCopy Code<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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.3.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>jQuery Mobile Example</h1>
</div>
<div data-role="content">
<p>Hello, World!</p>
</div>
<div data-role="footer">
<h4>Footer Text</h4>
</div>
</div>
</body>
</html>
在这个例子中,<div>
标签包含了 data-role
属性,用于指定元素的角色。<div data-role="page">
定义了一个页面,而其它 <div>
则定义了页面的不同部分,如标题、内容和页脚等。