在自举模型上载图像并加载新上传的图像

问题描述:

该模型将加载点击图标图像。

<div class="modal fade" id="profilePicModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
     <div class="modal-dialog"> 
      <div class="modal-content">   
       <div class="modal-body"><div id="jsoneditor"> 
        <img src="" id="profilePic" style="width: 100%; height: 100%;" > 
       </div></div> 
       <div class="modal-footer"> 
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
       </div> 
      </div> 
     </div> 
    </div> 

JS代码点击图标图像,然后打开模型更改模型上的新图像。

$("#image").on("click", function() { 
     $('#profilePic').attr('src', $(this).attr('value')); 
     $('#profilePicModal').modal('show'); 
     $('#profilePic').cropper({ 
     aspectRatio: 16/9, 
     crop: function(e) { 

     } 
}); 
    }); 
+2

你的问题是? – colburton

+0

其实我想要像gmail一样更改个人资料图片。 –

以下是根据用户选择更改图像的代码。这些图像与HTML文件放在同一个文件夹中。

<script> 
    function go(loc) { 
     document.getElementById('imagechange').src = loc; 
    } 
</script> 

<body> 
    <iframe id="imagechange" src="about:blank" width="1000" height="450" frameborder="0" scrolling="no"></iframe> 

    <form method="post"> 
     <input name="calendarSelection" type="button" Value=" River1" onclick="go('river2.jpg')" /> 
     <input name="calendarSelection" type="button" value=" GitHub" onclick="go('riverrafting.jpg')" /> 
     <input name="calendarSelection" type="button" value=" Wikipedia" onclick="go('Employee.jpg')" /> 

    </form> 

</body>