[CODING] How can I enable an html button after some Seconds?

Omoruyiik

Regular Member
Joined
Sep 15, 2015
Messages
295
Reaction score
77
I want to enable a button to become clickable on a page after a 5 seconds with code.

I'm currently putting up a landing page and I only want to enable a button to be clickable after 5 seconds.

How can I do this?

Note: I only understand basic Html as of now, kindly be a bit Explanatory. Thanks
 

phantasma

Jr. VIP
Jr. VIP
Joined
Dec 9, 2017
Messages
254
Reaction score
121
you should make a point to learn javascript, it does that.
 
Last edited:

The Undefined

Jr. VIP
Jr. VIP
Joined
Sep 28, 2017
Messages
261
Reaction score
146
Please copy paste from the following:

Code:
<button id="sample" disabled>Your text</button>
<script>
document.onreadystatechange = function() {
    if(this.readyState == 'complete') {
        setTimeout(function() {
            document.getElementById('sample').removeAttribute('disabled')
        }, 5000);
    }
}
</script>

Play with it a little bit to make it more customized (eg. change element id in the script tag and button tag, play with other attributes, etc.)
 

Omoruyiik

Regular Member
Joined
Sep 15, 2015
Messages
295
Reaction score
77
Please copy paste from the following:

Code:
<button id="sample" disabled>Your text</button>
<script>
document.onreadystatechange = function() {
    if(this.readyState == 'complete') {
        setTimeout(function() {
            document.getElementById('sample').removeAttribute('disabled')
        }, 5000);
    }
}
</script>

Play with it a little bit to make it more customized (eg. change element id in the script tag and button tag, play with other attributes, etc.)
Thanks I'm putting it to work now, I'm figuring how to make it work with my html button code, if I got questions I'd likely come back
 
Top