I am facing a challenge where I need to replace an active button with a deactivate button. The issue is that when I click on the active button, it does change to the deactivate button as expected. However, clicking again does not switch it back to the active state. Can someone help me out with this problem?
<td class="statusButtons">
<span><a href="#" class='status activeBtn'>Active</a></span>
<span><a href="#" class='status editBtn'>Edit</a></span>
<span><a href="#" class='status deleteBtn'>Delete</a></span>
</td>
The provided JavaScript code is:
const statusButtons=document.querySelector(".statusButtons");
const status=document.querySelector(".status");
const activeBtn=document.querySelector(".activeBtn");
activeBtn.addEventListener("click",changeA2D);
function changeA2D(){
activeBtn.style.visiblity='hidden';
activeBtn.parentElement.innerHTML=`<a href="#" class='status deactiveBtn'>Deactivate</a>`;
}