$(function() {
$('.pop').on('click', function() {
$('.imagepreview').attr('src', $(this).find('img').attr('src'));
$('#imagemodal').modal('show');
});
});
.modal-backdrop.in {
opacity: 0.8;
}
#imagemodal .modal-dialog {
width: 70%;
position: center;
}
@media (max-width: 987px) {
.pop:hover {
opacity: 100;
filter: alpha(opacity=100);
/* For IE8 and earlier */
}
}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-md-4">
<a href="#" class="pop">
<img src="images/powwow/powwow_01.jpg" style="width: 100%">
</a>
</div>
</div>
<div class="modal fade" id="imagemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span>
</button>
<img src="" class="imagepreview" style="width: 100%;">
</div>
</div>
</div>
</div>
I want to deactivate a modal on smaller screens like phones and tablets, while keeping it active on larger screens. I've tried using CSS media queries with `visibility:hidden` and `display:none`, but the results are not what I expected. I believe the onClick function needs to be disabled for smaller screens, but I'm struggling to figure out how to do that. Any suggestions on how to achieve this?