拖动后无法单击的元素
我的左侧有一些盒子。当它们被拖动时,它们会被克隆,因此您可以将任意数量的盒子放在想要的盒子上。
当它们被拖动到.sortable
时,我希望通过单击链接的x
来将它们删除。
<div class="draggable">
<div class="structure">
<div class="item1 e1" data-class="e1" data-parent="w1">New block <a href="javascript:;" class="remove">X</a></div>
<div class="item1 e2" data-class="e2" data-parent="w2">New headline <a href="javascript:;" class="remove">X</a></div>
</div>
</div>
<div class="sortable"></div>
这是我的脚本:
$(".sortable").sortable();
$(".structure .item1").draggable({
connectToSortable: ".sortable",
helper: "clone"
});
$(".remove").on("click", function () {
alert("Hello out there!");
});
不幸的是,此x
似乎无能为力。什么都没有发生。你知道我做错了什么吗?
I got some boxes on the left that are draggable. When they are dragged, they are cloned, so you can put as many boxes as you want.
When they are dragged to the .sortable
I want them to be removed by clicking on the x
of a link.
<div class="draggable">
<div class="structure">
<div class="item1 e1" data-class="e1" data-parent="w1">New block <a href="javascript:;" class="remove">X</a></div>
<div class="item1 e2" data-class="e2" data-parent="w2">New headline <a href="javascript:;" class="remove">X</a></div>
</div>
</div>
<div class="sortable"></div>
This is my Script:
$(".sortable").sortable();
$(".structure .item1").draggable({
connectToSortable: ".sortable",
helper: "clone"
});
$(".remove").on("click", function () {
alert("Hello out there!");
});
Unfortunately this x
doesn't seem to do anything. Nothing happens. Do you have an idea what I'm doing wrong?
Here you find a demo https://codepen.io/alphafrau/pen/WNMJpow
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是使用更正的事件委托。
https://api.jquery.com/on/
This is using the corrected event delegation.
https://api.jquery.com/on/