bootstrap modal close after 4 seconds or user click

前端 未结 4 1979
梦谈多话
梦谈多话 2020-12-24 14:49

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

相关标签:
4条回答
  • 2020-12-24 15:11
    setTimeout(function(){
      $('#Modal').modal('hide')
    }, 4000);
    

    //where modal's id is 'Modal'

    0 讨论(0)
  • 2020-12-24 15:15

    When calling setTimeout(), wrap your command in an anonymous function. Otherwise the command will be executed immediately.

    setTimeout(function() {$('#forgot-form').modal('hide');}, 4000);
    
    0 讨论(0)
  • 2020-12-24 15:16

    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');
    });
    
    0 讨论(0)
  • 2020-12-24 15:22
    $('#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.

    0 讨论(0)
提交回复
热议问题