Сообщение от Dolf
|
Возможно ли сделать так
|
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(function() {
let index = 0,
max = 4,
length = 5;
const hideCells = _ => document.querySelectorAll("#ex3 tr")
.forEach(({ cells }) => {
[...cells].forEach(({ style }, i) => style.display = i < index || i >= index + max ? "none" : "")
})
hideCells();
$(".scroll-table").on("click", "[data-up]", function() {
index += +this.dataset.up;
index = Math.max(0, Math.min(length - max, index));
hideCells()
})
});
</script>
</head>
<body>
<table class="table" id="ex3">
<tbody>
<tr>
<th>header 0</th>
<th>header 1</th>
<th>header 2</th>
<th>header 3</th>
<th class="nosort">header 4</th>
</tr>
<tr>
<td class="remove_button">0</td>
<td>1-1</td>
<td>1-2</td>
<td>1-3</td>
<td>1-4</td>
</tr>
<tr>
<td class="remove_button">0</td>
<td>2-1</td>
<td>2-2</td>
<td>2-3</td>
<td>2-4</td>
</tr>
<tr>
<td class="remove_button">0</td>
<td>3-1</td>
<td>3-2</td>
<td>3-3</td>
<td>3-4</td>
</tr>
<tr>
<td class="remove_button">0</td>
<td>4-1</td>
<td>4-2</td>
<td>4-3</td>
<td>4-4</td>
</tr>
</tbody>
</table>
<div class="scroll-table col-md-offset-2 col-md-2">
<button class="ComparisonHeader__arrowLeft btn btn-danger" id="left-button" data-up="-1">
<- </button>
<button class="ComparisonHeader__arrowRight btn btn-danger" id="right-button" data-up="1"> -> </button>
</div>
</body>
</html>