Tutorialsplane

Hide Bootstrap Modal JavaScript


Hide Bootstrap Modal JavaScript : Sometimes we need our own custom function to close the modal using javascript. Bootstrap provides modal hide event in javascript to close the modal. Here in this tutorial we are going explain how you can add a small piece of javascript to close the modal using the modal id. We will explain the functionality with example and demo with will make the thing more clear.


Hide Bootstrap Modal JavaScript Example

You can close the modal simply using the following method –

Hide Bootstrap Modal JavaScript : Example


Try it »

You can call this function anywhere you want. The above function will trigger action to close the bootstrap modal which have id #modal. $(selector)modal(‘hide’) is used to close the modal by the given selector. In this example we have used id #modal as selector. If you run the above example it will produce the output something like this –