Close Bootstrap Modal Popup inside JavaScript function

Last Reply 11 months ago By dharmendr

Posted 11 months ago

I want to close Bootstrap Modal Popup inside JavaScript function.

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



Posted 11 months ago Modified on 11 months ago

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() {