Jquery 如何在modal中实现引导映像预览
我正在尝试为每个图像提供引导模式权限。我怎样才能在我当前的代码中实现这一点。检查我的小提琴Jquery 如何在modal中实现引导映像预览,jquery,html,css,twitter-bootstrap,bootstrap-modal,Jquery,Html,Css,Twitter Bootstrap,Bootstrap Modal,我正在尝试为每个图像提供引导模式权限。我怎样才能在我当前的代码中实现这一点。检查我的小提琴 $images=$('.imageOutput') $(“.imageUpload”).change(函数(事件){ readURL(this); }); 函数readURL(输入){ if(input.files&&input.files[0]){ $.each(input.files,function()){ var reader=new FileReader(); reader.onload=函数
$images=$('.imageOutput')
$(“.imageUpload”).change(函数(事件){
readURL(this);
});
函数readURL(输入){
if(input.files&&input.files[0]){
$.each(input.files,function()){
var reader=new FileReader();
reader.onload=函数(e){
$images.append(“”)
}
reader.readAsDataURL(this);
});
}
}
$(函数(){
$('.pop')。在('click',function()上{
$('.imagepreview').attr('src',$(this.find('img').attr('src'));
$('#imagemodal').modal('show');
});
});
&时代;接近
工作小提琴:您已经在预览图像了。但您希望它在
引导程序中预览。这就是你要找的吗?是的,你是对的
$images = $('.imageOutput')
$(".imageUpload").change(function(event){
readURL(this);
});
function readURL(input) {
if (input.files && input.files[0]) {
$.each(input.files, function() {
var reader = new FileReader();
reader.onload = function (e) {
$images.append('<img src="'+ e.target.result+'" />')
}
reader.readAsDataURL(this);
});
}
}
$(function() {
$('.pop').on('click', function() {
$('.imagepreview').attr('src', $(this).find('img').attr('src'));
$('#imagemodal').modal('show');
});
});
<a href="#" class="pop">
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0d/Great_Wave_off_Kanagawa2.jpg" style="width: 400px; height: 264px;">
</a>
<a href="#" class="pop">
<img src="http://wallpapercave.com/wp/rZaowP9.jpg" style="width: 400px; height: 264px;">
</a>
<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>