how to hide a div containing loading.gif spinner by default and loads only when a tab is requesting data from a web api using axios get using javascript and css code example
Example 1: my loader is continously loading js
$('body').append('<div style="" id="loadingDiv"><div class="loader">Loading...</div></div>');
$(window).on('load', function(){
setTimeout(removeLoader, 2000);
});
function removeLoader(){
$( "#loadingDiv" ).fadeOut(500, function() {
$( "#loadingDiv" ).remove();
});
}
Example 2: display div while load
<script>
$(window).load(function() {
$('#loading').hide();
});
</script>