2014-10-28 36 views
3

我有一個按鈕被點擊下面的代碼後出現的AJAX裝載機:卸下阿賈克斯裝載機圖像之後的某個

jQuery(document).ready(function($){ 
{ 
     $.getElementById('form').onsubmit = function() { 
     $.getElementById('submit').style.display = 'block'; 
     $.getElementById('loading2').style.display = 'block'; 
     }; 
    }(document)); 
}); 

HTML:

<input type="submit" class="button alt" onclick="$(\'#loading\').show();" name="woocommerce_checkout_place_order"/>' 

我想阿賈克斯裝載機在10秒後消失。

請讓我知道

+0

您可以使用JavaScript的setTimeout – 2014-10-28 11:19:19

回答

1

您可以使用此10秒後,以隱藏自己的裝載機。

setTimeout(function() { 
    $('#loading').hide(); // I wasnt sure which one you wanted to hide 
    $('#loading2').hide(); 
}, 10000); 

也看着你的代碼即時消息不知道如果這將工作反正。此外,如果您使用jQuery,那麼您並不需要使用vanilla Javascript,因此您的代碼可以更改爲此。

jQuery(document).ready(function($){ 
    $('#form').submit(function() { 
     $('#submit').css('display', 'block'); 
     $('#loading2').css('display', 'block'); 
    }); 
}); 
+0

感謝這個工作 – user38208 2014-10-28 12:11:23

0
$(function() { 
// setTimeout() function will be fired after page is loaded 
// it will wait for 10 sec. and then will fire 
// $("#successMessage").hide() function 

setTimeout(function() { 
$("#loading").hide('blind', {}, 500) 
}, 10000); 
}); 

注:爲了使你裏面的setTimeout jQuery函數的工作,你應該把它包裝內

function() { ... }