-1
我在一次刪除一個圖像時遇到問題。當我雙擊時,所有圖像同時被刪除。我怎樣才能防止這種情況發生?這裏是我的腳本ondblclick所有圖像被刪除jquery
$(".bananas").on('dblclick', function(e) {
var whichtr = $(this).closest("div");
whichtr.remove();
});
$('img').on('click', function() {
$('#fotos').append('<div class="imgdrag"><img class="modal-content" src="' + $(this).attr('src') + '"/></div>');
$('.imgdrag').draggable();
$('#fotos').droppable();
$('.modal-content').resizable();
$(".download").attr("href", $(this).attr('src'));
$(".download").show();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fotos" class="bananas">
<img class="modal-content" id="imgdisplay" src="http://lorempixel.com/output/technics-q-c-640-480-8.jpg"/>
</div>
添加整個代碼或至少html。 –
您刪除容器。 (''dblclick',function(e){$(this).remove();});' – mplungjan
請用[mcve]更新代碼。您至少還缺少一張圖片,向我們展示您的意思 - 使用您需要的代碼更新代碼片段 – mplungjan