我想将已删除的项目附加到可排序列表中的目标可放置框中,但我无法将放置的项目附加到特定元素中。
我的jquery,
$(".sortable").sortable({ update: function(){ // php update. } }).disableSelection(); $( ".droppable" ).droppable({ activeClass: "ui-state-hover", hoverClass: "ui-state-active", drop: function( event, ui ) { var targetElem = $(this).attr("id"); $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped! inside " + targetElem ); alert(targetElem); var container = $( this ).find( "ul.dropped-items" ).css({border:"blue solid 1px"}); container.append(ui.draggable.clone()); ui.draggable.remove(); } });
被删除的项目应该附加到此元素中,
但它只是没有发生。 我错过了什么,我怎么能让它发挥作用?
jsfiddle测试页面 。
您可以删除元素上的绝对位置样式:
使用Javascript
... container.append(ui.draggable.clone().css({position: 'relative', left: 0, top: 0, width: 'auto', height: 'auto'})); ...
演示
或者,添加样式以执行相同操作:
CSS
.dropped-items li { position: relative !important; top: 0 !important; left: 0 !important; width: auto !important; height: auto !important; }
演示
以上就是jQuery教程分享jquery可排序和可放置 – 无法附加放置项?相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/557973.html