Modal jQuery or Bootstrap that receives email and name, automatically displayed when loading the page

Asked

Viewed 87 times

0

I tried the following code, but it’s not working

<script type="text/javascript">
	$(document).ready(function() {
   $('#myModal').modal('show');
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<div id="myModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      Conteudo
    </div>
  </div>
</div>

3 answers

1


The problem is you’re calling the jquery.minjs. after the code.

Try this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="CAMINHO_DO_BOOTSTRAP.MIN.JS_AQUI"></script>
<script type="text/javascript">
    $(document).ready(function() {
   $('#myModal').modal('show');
});
</script>
  • 1

    It worked Luiz! Thank you very much

1

Make a jQuery call after page loading, this way:

$(document).ready(function(){
    $('#modal').modal('show');
});
  • It’s not working. See below

  • I already have the loaded scripts and tb links in includes (I’m using codeigniter

  • Based on the code posted below you should change the div that has the "modal fade" classes to the modal id (#modal) to work by removing this id from the first div. I suggest you edit your question by placing the code so that it is correctly viewed by other users with the same question

  • Okay, see above, code posted

  • Rafael, you must include the jQuery script before using its functions, so put the jquery.min.js script before the code to show the modal in javascript.

0

<div id="#modal">
<div class="modal fade">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
<style>
$(document).ready(function(){
   **texto em negrito**     $('#modal').modal('show');
});
</style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.