jQuery Mobile Column-Toggle Table columnBtnText选项
jQuery Mobile是一个基于HTML5的用户界面系统,旨在使响应式网站和应用程序在所有智能手机、平板电脑和桌面设备上都能访问。列-切换表部件允许在带有复选框的列按钮的帮助下,隐藏/显示不太重要的列。
在这篇文章中,我们将学习jQuery Mobile Column-Toggle Table columnBtnText选项。columnBtnText选项设置了柱状按钮的文本,默认为’Columns…’,可以通过这个选项改变。
语法 :columnBtnText选项需要一个字符串值,并被初始化,如下所示。
$("#gfg-table-column-toggle").table-columntoggle({
columnBtnText: "Show columns"
});
要在初始化后得到,请使用以下语法。
var columnBtnTextOpt = $("#gfg-table-column-toggle")
.table-columntoggle("option", "columnBtnText");
要在初始化后进行设置,请使用以下语法。
$("#gfg-table-column-toggle").table-columntoggle(
"option", "columnBtnText", "Show columns");
CDN链接。为你的jQuery Mobile项目使用以下CDN。
<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>
例子:在下面的例子中,columnBtnText选项被设置为”Show columns “。
<!DOCTYPE html>
<html lang="en">
<head>
<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" id="gfgpage">
<div data-role="header">
<h1 style="color: green;">GeeksforGeeks</h1>
</div>
<div data-role="main" class="ui-content">
<h3> jQuery Mobile Column-Toggle Table columnBtnText Option</h3>
<table data-role="table" id="gfg-table-column-toggle"
data-mode="columntoggle"
class="ui-responsive table-stroke"
data-enhanced="false"
data-column-btn-text="Show columns">
<thead>
<tr>
<th>Sl No.</th>
<th>Article Title</th>
<th data-priority="2">Category</th>
<th data-priority="1">Topic</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td><a href=
"https://www.geeksforgeeks.org/hashing-data-structure/">
Hashing Data Structure</a>
</td>
<td>Coding</td>
<td>Data Structures</td>
</tr>
<tr>
<th>2</th>
<td><a href=
"https://www.geeksforgeeks.org/graph-data-structure-and-algorithms/">
Graph Data Structure And Algorithms</a>
</td>
<td>Coding</td>
<td>Data Structures</td>
</tr>
<tr>
<th>3</th>
<td><a href=
"https://www.geeksforgeeks.org/ml-multiple-linear-regression-using-python/">
ML | Multiple Linear Regression using Python</a>
</td>
<td>Machine Learning</td>
<td>Supervised Learning</td>
</tr>
<tr>
<th>4</th>
<td><a href=
"https://www.geeksforgeeks.org/implementing-dbscan-algorithm-using-sklearn/">
Implementing DBSCAN algorithm using Sklearn</a>
</td>
<td>Machine Learning</td>
<td>Unsupervised Learning</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
$("#gfg-table-column-toggle").table - columntoggle({
columnBtnText: "Show columns"
});
</script>
</body>
</html>
输出: