My JavaScript function seems to be malfunctioning. Whenever I remove the "d-none" class from an element, it briefly appears for about a second and then disappears again.
Here is the function responsible for toggling the visibility of the element:
function toggleElementVisibility() {
document.getElementById("form-element").classList.remove("d-none");
}
The following link triggers the function:
<a href="" class="btn btn-primary" id="toggle_visibility_button" onclick="toggleElementVisibility()">
TOGGLE VISIBILITY
</a>
This is the specific element that I want to show/hide:
<div class="d-none" id="form-element">
<p>Content inside the form element...</p>
</div>
I attempted to halt the script upon displaying the element, but it appears that the page reloads automatically.