<div onclick="k=this.dataset.k;t=event.target.textContent;this.dataset.k=+k+(t=='Next'&&1||t=='Back'&&-1||0);[...this.children].forEach((s,i)=>s.hidden=!(i==s))" data-k=1>
<section>
<h1>1</h1>
<button>Next</button>
</section>
<section hidden>
<h1>2</h1>
<button>Back</button>
<button>Next</button>
</section>
<section hidden>
<h1>3</h1>
<button>Back</button>
<button>Next</button>
</section>
<section hidden>
<h1>4</h1>
<button>Back</button>
</section>
</div>