Showing a modal When onclick method is called of <a>

Showing a modal When onclick method is called of <a>

本文关键字:of lt called gt is modal When onclick method Showing      更新时间:2023-09-26

我使用的是salesforce platofrm.在该程序中,我只能访问按钮的onclick功能

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>

而不是设置这些属性href="#myModal" role="button" class="btn" data-toggle="modal

当用户使用javascript的onclick函数点击链接时,如何显示模态请指导

点击按钮,您可以使用文档中给出的show方法

$('#myModal').modal('show')

演示:Plunker

您可以使用切换来隐藏显示,不需要使用显示和隐藏

$("#myModalID").modal('toggle');
$('#myModalID').modal('show');
$('#myModalID').modal('hide');