I am new to JS and facing some challenges which may seem simple.
what i want to do is:
- a user clicks on a button that states 'submit'
- when the button is clicked the word 'submit' changes to 'please wait...' & button is disabled
- the button is disabled for 2 seconds
- after 2 seconds the word 'please submit..' changes back to 'submit' & the button becomes activated (its no longer disabled)
i have written the below code. Any advise on this would be much appreciated
html
<form action="#" method="post">
<input type="button" name="submit" value="Submit" class="submit_wide" id="myBtn" >
</form>
javascript
$(".submit_wide").click(function () {
$(this).val('Please wait..');
$(this).attr('disabled', true);
setTimeout(function() {
$(this).attr('disabled', false);
$(this).val('Submit');
}, 2000);
});