Dave G. Dave G. - 3 months ago 9
CSS Question

Bootstrap different pop up windows after button click

I want to have pop up windows on a website after user clicks the buttons I want to display a pop up window. However I have managed to do that but the problem is that the same text shows on all button clicks.

<button type="button" class="w3-btn w3-theme-d1 w3-margin-bottom" data-toggle="modal" data-target="#moreinfo"><i class="fa fa-thumbs-up"></i>  Find out more</button>

<div id="moreinfo" class="modal fade" role="dialog">

<div class="modal dialog">

<div class="modal-content">

<div class="modal-header">
fdssdsdffsgffdgdf
</div><!--end of modal header-->

<div class="modal-body">
fds
</div><!--end of modal content-->

</div><!--end of modal content-->

</div><!--end of modal dialog-->

</div><!--en dof more info div-->


that is my code, I have the same styles for the windows but I just want to have different text on each of them

Please help

Answer

Try this for different modals

 <div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal1">Open Modal</button>
  <!-- Modal 1-->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div> <!--End of Modal 1-->
  <!-- Modal 2-->
  <div class="modal fade" id="myModal1" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header 1</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal 1.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close 1</button>
        </div>
      </div>

    </div>
  </div>
  <!--End of Modal 2-->
</div>