[英]How to display limited records instead of all records using jquery
在我的 iframe 中,我有很多記錄,但我的要求是只顯示 4 條記錄而不是全部。 我將提供一個“顯示全部”鏈接,一旦點擊顯示全部鏈接,我們必須在另一個選項卡中顯示所有記錄。
我在這里添加了一個帶有表格的示例代碼,希望它能幫助你。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<tbody>
<tr>
<td>1</td>
<td>Alice</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
</tr>
<tr>
<td>3</td>
<td>Carol</td>
</tr>
</tbody>
</table>
<button class="show-all">Show all</button>
<button class="show-default">Show default</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$("table > tbody > tr").hide().slice(0, 2).show();
$(".show-all").on("click", function() {
$("tbody > tr", $(this).prev()).show();
});
$(".show-default").on("click", function() {
$("table > tbody > tr").hide().slice(0, 2).show();
});
</script>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.