Utilize bootstrap-modal and replace the button
with a
:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<a href="#" data-toggle="modal" data-target="#myModal">
Open modal from a
</a>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Edit to you comment
Is there a way to display the content of a text file in that modal? For example, viewing in the modal?
Use:
$.get( "http://humanstxt.org/humans.txt", function( data ) {
$('.modal-body').html= data;
});
Alternatively, with .ajax
:
$(document).ready(function(){
$.ajax({url: "http://humanstxt.org/humans.txt", success: function(result){
$('.modal-body').html(result);
}});
});