如何使用jQuery Mobile创建一个基本的弹出按钮
jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。在这篇文章中,我们将使用jQuery Mobile创建一个基本的弹出按钮。
方法:添加你的项目所需的jQuery Mobile脚本。
<link rel=”stylesheet” href=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”http://code.jquery.com/jquery-1.11.1.min.js”></script>
<script src=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>
我们将使用不同类型的ui类来制作一个简单的弹出按钮。为了添加弹出窗口,我们将使用data-role="popup"属性到div元素。data-rel="popup"属性用于告诉框架在点击链接时打开弹出窗口。
示例:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src=
"http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script src=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
</script>
</head>
<body>
<center>
<h1>GeeksforGeeks</h1>
<h4>
Basic popup button using jQuery Mobile
</h4>
<a href="#basicPopup" data-rel="popup"
class="ui-btn ui-corner-all ui
shadow ui-btn-inline"
data-transition="pop">Basic Popup</a>
<div data-role="popup" id="basicPopup">
<p>It is a simple example of basic popup</p>
</div>
</center>
</body>
</html>
输出:

极客教程