jQuery Mobile Listview autodividers选项
jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。
在这篇文章中,我们将使用jQuery Mobile Listview autodividers选项。这个选项是由 “listview.autodividers “扩展给出的,当这个选项的值被设置为 “true”,那么列表视图的项目就会自动创建分隔线。
语法:
使用autodividers选项初始化列表视图。
$( ".selector" ).listview({
autodividers: true
});
- 设置autodividers选项。
$( ".selector" ).listview( "option", "autodividers", true );
- 获得自动分割器选项。
var themeClass = $( ".selector" )
.listview( "option", "autodividers" );
CDN链接:首先,添加你的项目需要的jQuery Mobile脚本。
<link rel=”stylesheet” href=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css”>
<script src=”//code.jquery.com/jquery-3.2.1.min.js”></script>
<script src=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js”></script>
例子:这个例子演示了jQuery Mobile Listview autodividers选项。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1">
<link rel="stylesheet" href=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css">
<script src=
"//code.jquery.com/jquery-3.2.1.min.js">
</script>
<script src=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js">
</script>
</head>
<body>
<center>
<div data-role="page">
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3>jQuery Mobile Listview autodividers Option</h3>
<div id="divID">
<div role="main" class="ui-content">
<ul data-role="listview">
<li><a href="index.html">GeeksforGeeks</a></li>
<li><a href="index.html">GFG</a></li>
<li><a href="index.html">gfg</a></li>
</ul>
</div>
</div>
<input type="button" id="Button"
value="Value of the autodividers Option">
<div id="log"></div>
</div>
</center>
<script>
(document).ready(function () {
("#divID").listview({
autodividers: true
});
("#divID").listview("option", "autodividers", true);
("#Button").on('click', function () {
var a = ("#divID").listview("option", "autodividers");
("#log").html(a);
});
});
</script>
</body>
</html>
输出:
jQuery Mobile Listview自动划分器选项