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

<script type="text/javascript">
function closeModal(){
        $('#modal').modal('close');
  }
</script>

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 –

Hide Bootstrap Modal JavaScript Example


Advertisements

Add Comment

📖 Read More





Warning: mkdir(): No such file or directory in /home/u312555568/domains/tutorialsplane.com/public_html/wp-content/themes/Modernia/footer.php on line 406