BarsBelka,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div class="pagenumbers" id="pagination">
<button id="previous-page">Назад</button>
<div class="number-of-page"></div>
<button id="next-page">Далее</button>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const prevBtn = document.getElementById('previous-page');
const nextBtn = document.getElementById('next-page');
const numberOfPage = document.querySelector('.number-of-page');
let pageNumber = 1
numberOfPage.textContent = pageNumber;
function page(up = 0) {
pageNumber += up;
//posts.innerHTML='';
numberOfPage.textContent = pageNumber;
//getPage()
prevBtn.hidden = pageNumber == 1;
}
page()
// Пагинация
nextBtn.addEventListener('click', () => page(1))
prevBtn.addEventListener('click', () => page(-1))
});
</script>
</body>
</html>