How would I set a timeout for a bootstrap modal? After getting the ajax data back that the message returned by php contains the term success
, I want to give the
setTimeout(function(){
$('#Modal').modal('hide')
}, 4000);
//where modal's id is 'Modal'
When calling setTimeout(), wrap your command in an anonymous function. Otherwise the command will be executed immediately.
setTimeout(function() {$('#forgot-form').modal('hide');}, 4000);
The following code is used for hiding the model on an onClick
event. Use the classname for the onClick
listener and the modal id as the selector to hide.
$('.class_name').on('click',function(){
$('#modal_id').modal('hide');
});
$('#submit1').click(function(){
setTimeout("$('#myModal').modal('hide');",3000);
});
this is working for popup delaying 3 seconds in closing.
please check with the $('#submit1')
for this click I have written the code.