- How to open the modal popup using a link instead of button?
- How do I link a button to a modal?
- Should a button or a link open a modal?
How to open the modal popup using a link instead of button?
Just change the button for <a href="#" id="myBtn">Open Modal</a> , your current script will assign the onclick method.
How do I link a button to a modal?
To trigger the modal window, you need to use a button or a link. Then include the two data-* attributes: data-toggle="modal" opens the modal window. data-target="#myModal" points to the id of the modal.
Should a button or a link open a modal?
In almost all other cases, your modal is loaded on the same page and is in no way navigated using a url link (except through ajax for accessing data possibly, which doesn't count). Hence it is a custom functionality and a button is the appropriate choice.