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

Omoruyiik

Regular Member
Joined
Sep 15, 2015
Messages
294
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
 
you should make a point to learn javascript, it does that.
 
Last edited:
Javascript.

Make a function using a timer after 5seconds enable button by using its properties
 
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.)
 
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
 
Back
Top