func2
works and disappears after 2 seconds, but the first func1
does not work, the button that I have hidden is not displayed. It worked for me before I added the other javascript func2
, but not anymore.
This is my code:
window.onload = function() {
setTimeout(func1, 2000);
};
function func1() {
document.getElementById("hiddenbutton").className = "show";
}
window.onload = function() {
setTimeout(func2, 2000);
};
function func2() {
document.getElementById("div2").className = "hide";
}
.hide{
display:none;
}
.show{
display:block;
}
<div id="hiddenbutton" class="hide">
<p>If the URL is correct, you can avoid waiting and touch the following button.</p>
<form action="'.$longlink.'" method="post">
<input type="submit" id="button-'.$shortenedlink.'" disabled="disabled" value="Redirect">
</form>
</div>
<br>
<div id="div2" class="show">
<p>The button will appear after 2 seconds of loading the page.</p>
</div>