我选择图像后如何打开模态?

时间:2017-02-06 11:12:01

标签: jquery bootstrap-modal

我想要的是当用户选择图像打开模态时,它可以选择裁剪图像。这是我的Fiddle,在那里他可以裁剪图像,但是在视野中。

  <input type='file' id="imgInp" />
  img id="blah" class="crop" src="#" alt="your image" />
  <input type="hidden" id="x" name="x" />
  <input type="hidden" id="y" name="y" />
  <input type="hidden" id="w" name="w" />
  <input type="hidden" id="h" name="h" />

2 个答案:

答案 0 :(得分:1)

看着你的小提琴,你应该知道你已经够近了。请执行以下操作。

$("#imgInp").change(function(){
     console.log(this);
     readURL(this);
     $("#yourModal").modal('show);
});

答案 1 :(得分:0)

而不是使用$(“#yourModal”)。show();使用$('#yourModal')。modal('show');

使用以下代码:

      $('#imgInp').change(function(){

        $('#yourModal').modal('show');

      });

这绝对适合你。