Just trigger the link click where you want.
$(".myLink").trigger('click'); // or:
$(".myLink").click();
Edit: In your question you're using the wrong handler. $("modal")
would look for a <modal>
element. You're looking for $('#modal')
.
If you want to have the dialog pop up without a link at all, you should be able to set it hidden using display: none
in the CSS or style attribute, and then trigger it via code anyways.
Or, you can use Fancybox for added flexibility, and they're more open about how to use their dialog boxes without attaching to a specific link, but rather any element and decide what goes inside and how to trigger it.