Lord Vermillion Lord Vermillion - 23 days ago 6
jQuery Question

perform data-toggle with jquery

I have a button that toggles a bootstrap modal.

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">


I want to do the same thing with a jquery function. Is this possible?

Answer

give your button id and hide it:

CSS:

#btnTrigger
{
display:none;
}

HTML:

<button class="btn btn-primary btn-lg" id="btnTrigger" data-toggle="modal" data-target="#myModal">

and on someother event or condition just click it programmatically:

JQuery:

$('#btnTrigger').click();

In Result, popup will be displayed.