Twitter Bootstrap: How to close modal / popover programmatically with jQuery

for bootstrap modal

Try $('#myModal').modal('hide')

For bootstrap popover

I just saw you are talking about a bootstrap dropdown not bootstrap modal:

In this case your approach is not bad, just remove the open class of the parent element. In the example from the link above the first dropdown element has an id of "drop3", so to programatically close it you can do:

$('#drop3').parent().removeClass("open");

To close bootstrap modal you can use 'hide' as option to modal method as follow

 $('#modal').modal('hide');

Please take a look at working fiddle here


Just a by the way; you can also trigger a close button click on the modal's close button like so:

$('.close').click();

UPDATE

The above method may have been a bit hacky, so your better off using the default Bootstrap modal method

$('#modal-id').modal('hide');