简体   繁体   中英

Bootstrap modal on page load is not happening

I have a login/signup modal it is working fine,but i need to open the modal when the page loads I have taken the code from here

I have changed my code like this and i need to open the reset password modal when the page loads.

Modal Code

 <div id="cd-reset"> 
            <div class="row">
              <div class="col-md-8 col-md-offset-2 Mask2" align="center">
              </div>
            </div>
            <div class="row">
              <div class="col-md-12">

              </div>           
            </div>
          </div> 

    <script type="text/javascript">
        $(window).on('load',function(){
            $('#cd-reset').modal('show');
        });
    </script>

but its not working. when I load the page it does not display the modal/popup can anyone suggest me how to do. Thanks in advance.

Ideally the bootstrap modals need certain classes to give you the feel. You need to use the exact classes to get the modal pop-up. Also, in your code there is no content (text) and thus why you're not seeing anything. Code should look like below.

<div class="modal fade" id="myModal">
    <div class="modal-dialog">
      <div class="modal-content">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <p>Some text in the modal.</p>
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM