【问题标题】:how to overwrite the logo如何覆盖徽标
【发布时间】:2020-06-24 06:26:34
【问题描述】:

我想通过标志上的预览照片删除标志 我的脚本是

        function preview_image(event)
        {
         var reader = new FileReader();
         reader.onload = function()
         {
          var output = document.getElementById('output_image');
          output.src = reader.result;
         }
         reader.readAsDataURL(event.target.files[0]);
        }
<label for="id_Photo"><img height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
        <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
        <img height="120" width="120" id="output_image"/>

【问题讨论】:

  • 我想通过 logo 上的预览照片删除 logo 我不明白,你不想预览还是要覆盖 imglogo.png
  • 是的,我想覆盖

标签: javascript html django


【解决方案1】:

试试

<label for="id_Photo"><img  id="output_image" height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
            <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
       

而不是

<label for="id_Photo"><img height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
        <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
        <img height="120" width="120" id="output_image"/>

【讨论】:

    【解决方案2】:

    你可以像这样使用output_image的预览图

            function preview_image(event)
            {
             var reader = new FileReader();
             reader.onload = function()
             {
              var output = document.getElementById('output_image');
              output.src = reader.result;
             }
             reader.readAsDataURL(event.target.files[0]);
            }
    <label for="id_Photo"><img height="120" width="120" id="output_image" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
          <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
           

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-22
      • 1970-01-01
      • 1970-01-01
      • 2012-05-07
      • 2015-05-31
      • 2019-03-05
      • 1970-01-01
      • 2022-01-20
      相关资源
      最近更新 更多