Close Bootstrap Modal Popup inside JavaScript function

Last Reply on Sep 19, 2018 05:18 AM By dharmendr

Posted on Sep 19, 2018 05:17 AM

I want to close Bootstrap Modal Popup inside JavaScript function.

<button type="button" class="close" data-dismiss="modal">&times;</button> 



Posted on Sep 19, 2018 05:18 AM Modified on on Sep 19, 2018 08:37 AM

Hi mukesh1,

Refer below article.

Dismiss (Close) Bootstrap Modal Popup programmatically

Check this example. Now please take its reference and correct your code.


<!-- Bootstrap -->
<script type="text/javascript" src=''></script>
<script type="text/javascript" src=''></script>
<link rel="stylesheet" href=''
    media="screen" />
<!-- Bootstrap -->
    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#MyPopup">
        Open Modal</button>
<!-- Modal Popup -->
<div id="MyPopup" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" onclick="CloseModal()">
                <h4 class="modal-title">
            <div class="modal-body">
                Welcome to
            <div class="modal-footer">
                <input type="button" id="btnClosePopup" value="Close" class="btn btn-danger" onclick="CloseModal()" />
<!-- Modal Popup -->
<script type="text/javascript">
    function CloseModal() {