Here are some HTML codes I've been working with:
<button id="hide" onclick="hide()">Hide</button>
<p id="pb">This paragraph has minimal content.</p>
My goal is to have the paragraph hide first when the button is clicked, followed by an alert() popup. Despite my efforts and extensive searching, I haven't been able to achieve the desired outcome. Below are my initial CSS and JS codes:
CSS:
.hide {
display: none;
}
JS
var button = document.getElementById("hide");
var p = document.getElementById("pb");
function hide(){
p.classList.add("hide");
alert("The paragraph is now hidden!");
}
In the current setup, the alert popup appears before the paragraph hides. This sequence is not what I intended. Your help would be greatly appreciated!