I have a JavaScript function that displays text when a button is clicked. The issue I am facing is that the text appears momentarily and then disappears after the page is reloaded.
Below is the paragraph that shows the text once the button is clicked:
<p class="lead" id="class"><strong style="color: red; font-size: 15px; display: none;"></strong></p>
Here is the button in question:
<button type="submit" class="btn btn-primary" onclick="myFunction()">Search</button>
This is the script for my function:
<script>
function myFunction() {
document.getElementById("class").innerHTML = "Class current balance total";
}
</script>
Is there a way to ensure that the text remains visible even after the page reloads?
Note: I am still learning about JavaScript and its functionalities.