Reputation: 1
I want a Preloader on the bases of 1 and O variable to change is GIF image which is overlay on background image. if i change variable 1 then show check GIF and if i change variable with 1 then show cross GIF.
var status_val;
(function( $ ) {
$(".validation" ).change(function() {
status_val = $(this).val();
changeStatus(status_val);
});
function changeStatus (status_val){
if ( status_val == 1){
$('#check, #cross').hide();
$('#check').show();
//setTimeout('$("#cross").show()',2000);
} else{
$('#check, #cross').hide();
$('#cross').show();
//setTimeout('$("#check").show()',2000);
}
}
}) (jQuery);
Upvotes: 0
Views: 67
Reputation: 292
(function() {
$('.validation').change(function(){
changeStatus($(this).val())
})
})
function changeStatus(val) {
if (val) {
$('#check, #cross').hide()
setTimeout(function(){ $('#check').show() },2000)
} else {
$('#check, #cross').hide()
setTimeout(function(){ $('#cross').show() },2000)
}
}
Read more example about setTimeout() here
Upvotes: 1
Reputation: 32354
Jquery show has a duration parameter that determines how long the animation will take
$('#cross').show(2000);
Upvotes: 0