jQuery Mobile Popup tolerance选项
jQuery Mobile是一种基于网络的技术和伟大的构建网页的UI界面,可用于制作可在所有类型的智能手机、平板电脑和台式机上访问的网站的响应内容。
在这篇文章中,我们将使用jQuery Mobile Popup tolerance选项来设置弹出窗口或页面的相应边缘的最小距离。”30,15,30,15″是默认的公差值。
这些值可以用四种方式指定:
- 一个空字符串,即null。
- 一个单一的数字。
- 两个用逗号隔开的数字。
- 四个用逗号隔开的数字。
语法:参数以上述指定的方式取值。
$( ".selector" ).popup({
tolerance: "0,0"
});
- 获取默认选项的语法。
var tolerance = $( ".selector" ).popup( "option", "tolerance" );
- 设置默认选项的语法。
$( ".selector" ).popup( "option", "tolerance", "0,0" );
CDN链接:以下是你的项目中需要的jQuery Mobile脚本,请将这些脚本加入你的项目中。
<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>
例子:这个例子描述了jQuery Mobile Popup tolerance选项的用途。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible"
content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<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>
<center>
<h1 style="color:green;">GeeksforGeeks</h1>
<h3>jQuery Mobile Popup tolerance Option</h3>
<div role="main" class="ui-content">
<a href="#divID" data-rel="popup">
GeeksforGeeks
</a>
<div data-role="popup" id="divID"
data-tolerance="30,15,30,15"
data-theme="b">
<p>
A Computer Science portal for geeks.
</p>
</div>
</div>
<input type="button" id="Button"
width="50%"
value="Value of the tolerance option">
<h3><span id="gfg"></span></h3>
</center>
<script>
(document).ready(function () {
("#Button").on('click', function () {
var tolerance = ( "#divID" ).popup( "option", "tolerance" );
("#gfg").html(tolerance);
});
});
</script>
</body>
</html>
输出:
jQuery Mobile Popup tolerance选项