Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

i am using a salesforce platofrm.in which i have access to only onclick function of a button .i have to launch a modal like this code

<!-- 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>

instead of setting these attributes href="#myModal" role="button" class="btn" data-toggle="modal

how to show modal when user click on the link using onclick function of javascript please guideline

like image 364
Ritesh Mehandiratta Avatar asked Nov 19 '25 18:11

Ritesh Mehandiratta


1 Answers

On click of the button you can use the show method as given in the documentation

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

Demo: Plunker

like image 198
Arun P Johny Avatar answered Nov 22 '25 06:11

Arun P Johny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!