Here this blog post all about how to open the modal box by using function. Now you can get it below examples step by step.
Before doing all the bootstrap min.js and CSS must be include in your html page.
Step-1:
Modal Box HTML-
1 2 3 4 5 6 7 | <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> . . . </div> |
Step-2:
Calling function using a href
1 | <a href="javascript;" onclick="somefunction()">Open Modal</a> |
Below exampleModal Id is modal box HTML Id.
Step-3:
1 2 3 4 5 6 7 8 9 | <script> function somefunction(){ $("#exampleModal").modal('show'); } </script> |