的右上角刪除按鈕我有,其中,選擇的圖像文件之後,示出了圖像預覽文件輸入,這裏是jQuery代碼如何顯示在圖像
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
};
</script>
的Html代碼 - >
<input type="file" name="image_file" id="cretor" accept="image/*" onchange="loadFile(event)">
<img id="output" width="80" height="80">
以上代碼在選擇圖像後立即生成圖像預覽,但是如何顯示圖像右上角的刪除按鈕並重置文件輸入並刪除該圖像
這裏是我試過的在圖像的右上角顯示刪除按鈕
<div class="img-wrap">
<button id="clear" onclick="twz()">x</a>
<img src="blob:https://www.example.com/c880bfa4-25d0-4e2b-91e4-d722b864cc79" id="output">
</div>
CSS
.img-wrap {
position: relative;
}
.img-wrap .close {
position: absolute;
top: 2px;
right: 2px;
z-index: 100;
}
現在,我怎麼能生成按鈕,將其放置在右上角,因爲使用loadFile函數只生成圖像預覽
快速觀察...