On the main page, I have a button that opens a modal when clicked. Inside the modal, there is a form with a submit button that closes the modal and returns to the main page. After closing the modal, I want to change the HTML button on the main page to plain text. How can I replace the main button on the main page once the modal is closed?
function handleSubmit() {
alert('yes');
var replacement = document.getElementById('mainButton');
replacement.style.display = 'none';
}
<body>
<button id="mainButton"> Click here </button>
<div class="modal">
<form onsubmit="handleSubmit()">
<input type="text">
<button> Done </button>
</form>
</div>
</body>
In my `handleSubmit` function, I attempted the following:
Removing the button using:
document.getElementById('mainButton').innerHTML = '';
I also tried: document.getElementById('mainButton').style.display = 'none'