The idea of the script is to disable the button for 1500ms after if was pressed. Button press activate an animation of "loading bar". After 1500ms script should work again.
The problem is that only setTimeout method doesn't work. Animation works well then button gets disabled, but after 1500ms it doesn't become enable.
Thankful for any help.
$(document).ready(function() {
$('button').click(function(){ // <-- works fine
var width = Math.floor(Math.random() * (231 - 23) + 23); // <-- works fine
$('.bar div').animate({width: width}, 1500); // <-- works fine
$('.bar div span').text(Math.floor((width*100)/230) + '%');// <-- works fine
var intervalID = setInterval(function() { // <-- works fine
$('button').prop('disabled', true)}, 50); // <-- works fine
setTimeout (function() { // <-- this doesn't work
clearInterval(intervalID)}, 1500); // <-- this doesn't work
});
});