简体   繁体   English

引导模态 HTML

[英]Bootstrap Modal HTML

I am currently developing a website and I am having some issues with a modal.我目前正在开发一个网站,但我在使用模式时遇到了一些问题。

So this is what I have so far:所以这就是我到目前为止所拥有的:

HTML: HTML:

  <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h2 class="modal-title fs-5" id="exampleModalLabel">Resultados</h2>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <h4>A tua média final de secundário é: </h4>
          <br>
          <br>
          <br>
          <h6>A tua média de acesso ao Ensino Superior é: </h6>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" style="background: #4a58ce; outline: none;">Ok</button>
        </div>
      </div>
    </div>
  </div>

  
  <button type="button" class="btn btn-primary" id="clicktoshow">
    Launch demo modal
  </button>

JS:记者:

  var buttonc = document.querySelector("#clicktoshow");
  buttonc.addEventListener("click", triggermodal);

  $(document).ready(function triggermodal() {
    $("#exampleModal").modal();
  });

Right now when I use javascript to trigger this modal after clicking the button nothing happens.现在,当我在单击按钮后使用 javascript 触发此模式时,什么也没有发生。 I have tried multiple solutions and still can't figure it out.我已经尝试了多种解决方案,但仍然无法弄清楚。

Note: I am bit new to web developing注意:我对 web 开发有点陌生

You can open the modal by adding a click event listener using jQuery. Once the button #clicktoshow is clicked, the #exampleModal will be shown.您可以通过使用 jQuery 添加点击事件侦听器来打开模式。单击按钮#clicktoshow后,将显示#exampleModal The code is-代码是-

$('#clicktoshow').on('click', function(){     
    $('#exampleModal').modal('show') 
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM