Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在modal中实现引导映像预览_Jquery_Html_Css_Twitter Bootstrap_Bootstrap Modal - Fatal编程技术网

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">&times;</span><span class="sr-only">Close</span></button>
            <img src="" class="imagepreview" style="width: 100%;" >
          </div>
        </div>
      </div>
    </div>