[英]Drag nested li doesn't work
I am using jquery-ui for sort and drag https://johnny.github.io/jquery-sortable/ .. But it doesn't append in li.. The code is like 我正在使用jquery-ui进行排序并拖动https://johnny.github.io/jquery-sortable/ .。但是它没有用li附加。代码就像
$("#example3 ul").sortable({ placeholder: "ui-state-highlight", connectWith: '#example3 ul' });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <div id="example3"> <ul> <li >Item 1 <ul> <li>Item 1 1</li> <li>Item 1 2</li> <li>Item 1 3</li> </ul> </li> <li >Item 2<ul></ul></li> <li >Item 3<ul></ul></li> <li >Item 4<ul></ul></li> </ul> </div>
Problem is, that the empty 'ul'-Tags does not have any space and are hidden (size is equals zero). 问题是,空的'ul'-Tags没有任何空间并且被隐藏了(大小等于零)。 Just add a small padding to each element, then you can drag your element there.
只需在每个元素上添加一个小的填充,然后就可以将元素拖到那里。 Here, have a look:
在这里,看看:
$("#example3 ul").sortable({ placeholder: "ui-state-highlight", connectWith: '#example3 ul' });
#example3 ul{ padding-bottom: 0.3em; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <div id="example3"> <ul> <li >Item 1 <ul> <li>Item 1 1</li> <li>Item 1 2</li> <li>Item 1 3</li> </ul> </li> <li >Item 2<ul></ul></li> <li >Item 3<ul></ul></li> <li >Item 4<ul></ul></li> </ul> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.