jQuery 在 DOM 中移动 div
我知道这个问题已经被问过很多次了,但我不明白我的代码有什么问题。
我有一系列 DIV
“列”,其中包含一些“对象”DIV
。我正在尝试使用下面的代码将对象 DIV
从一列移动到另一列。
我没有收到任何错误,客户端上没有收到任何错误,也没有在调试中提示任何错误。
谁能建议为什么以下不起作用?
$(".column-heading").droppable({
accept: ".column-item",
drop: function (ev, ui) {
//alert(this.id);
//alert(ui.draggable.attr("id"));
$(ui.draggable.attr("id")).appendTo($(this).parent());
}
});
我尝试添加/删除的示例列是:
<div class="column">
<div id="COL_1" class="column-heading">Status 1</div>
<div id="OBJECT_1" class="column-item">Agreement 1</div>
<div id="OBJECT_2" class="column-item">Agreement 2</div>
</div>
I know this has been asked many times, but I don't understand what is incorrect about my code.
I have a series of DIV
'columns' containing some 'object' DIV
s. I'm trying to move object DIV
s from one column to another using the code below.
I don't receive any errors, just nothing on the client and nothing to suggest in debug that anything is amiss.
Can anyone suggest why the following doesn't work?
$(".column-heading").droppable({
accept: ".column-item",
drop: function (ev, ui) {
//alert(this.id);
//alert(ui.draggable.attr("id"));
$(ui.draggable.attr("id")).appendTo($(this).parent());
}
});
A sample column I am trying add/remove from is:
<div class="column">
<div id="COL_1" class="column-heading">Status 1</div>
<div id="OBJECT_1" class="column-item">Agreement 1</div>
<div id="OBJECT_2" class="column-item">Agreement 2</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
#
与 ID 连接到选择器中。或者,我相信 ui.draggable 已经是一个 jQuery 对象,所以尝试:
You would need to concatenate
#
into the selector with the ID.Or, I believe
ui.draggable
is a jQuery object already, so try: