-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