How to activate the Bootstrap modal-backdrop?

后端 未结 2 739
猫巷女王i
猫巷女王i 2020-12-29 03:03

I want to put up an overlay on my screen while some ajax stuff is running. Building my own overlay div isn\'t a big deal, but, since I\'m already using Bootstrap, I figure

2条回答
  •  礼貌的吻别
    2020-12-29 03:42

    Just append a div with that class to body, then remove it when you're done:

    // Show the backdrop
    $('').appendTo(document.body);
    
    // Remove it (later)
    $(".modal-backdrop").remove();
    

    Live Example:

    $("input").click(function() {
      var bd = $('');
      bd.appendTo(document.body);
      setTimeout(function() {
        bd.remove();
      }, 2000);
    });
    
    
    
    

    Click the button to get the backdrop for two seconds.

提交回复
热议问题