How to open a Bootstrap modal without jQuery or bootstrap.js javascript?

前端 未结 3 2105
我寻月下人不归
我寻月下人不归 2021-02-19 06:47

I\'m working on a VERY LIGHT survey application. This application runs in third world countries in locations with very limited connection.

We found that the loading-tim

3条回答
  •  无人及你
    2021-02-19 06:51

    You don't need any css style. You should create the bootstrap modal in your HTML, then in your js, you have to simply give it some style according to the following description:

    var locModal = document.getElementById('locModal');
    var btnclose = document.getElementById('w-change-close');
    var btnShow= document.getElementById('w-change-location');
    
    
    //show the modal
    btnShow.addEventListener('click', (e) => {
        locModal.style.display = "block";
        locModal.style.paddingRight = "17px";
        locModal.className="modal fade show"; 
    });
        //hide the modal
        btnclose.addEventListener('click', (e) => {
            locModal.style.display = "none";
            locModal.className="modal fade";
    });
    

    The HTML should be like this:

    
    
        
        
    

提交回复
热议问题