JSFiddle - React, Tailwind, and code Playground

HTML

<div id="div-1"> 1 </div>
<div id="div-2" style="display: none"> 2 </div>
<div id="div-3" style="display: none"> 3 </div>
<div id="div-4" style="display: none"> 4 </div>

<a id="next" href="#">next</a>

JavaScript

var counter = 1;
var button = document.getElementById('next');

button.addEventListener("click",function(){
	var currentDiv = document.getElementById('div-'+counter);
	currentDiv.remove();
	var nextDiv = document.getElementById('div-'+counter+1);
    alert(nextDiv); // why does it return null
    alert('div-'+counter+1); // while this doesn't?
	nextQuestion.style.display = "block";
	counter++;
},true);