简体   繁体   English

如何在没有鼠标的jQuery UI Sortable中移动列表元素,纯粹在jQuery中?

[英]how do I move list elements in jQuery UI Sortable without the mouse, purely in jQuery?

I want to just set up a link that allows the user to jump a given sortable list element to the top of the list. 我想设置一个链接,允许用户将给定的可排序列表元素跳转到列表顶部。 I need something like 我需要类似的东西

$('.sortable li:last-child').move('.sortable li:first-child');

...where I can just cause a link to pop any list element up to the top of the list. ...我可以在其中生成一个链接,将任何列表元素弹出到列表顶部。

Never mind! 没关系! I found the answer. 我找到了答案。 $(id).prependTo($('#list')); $(ID).prependTo($( '#名单'));

Not sure if it's the best solution but this should work. 不确定它是否是最佳解决方案,但这应该有效。

$('.sortable li:last-child').live('click', function() {
    $(this).prependTo('.sortable');
});

Kind of hard to help further without seeing more code. 没有看到更多代码,有点难以进一步帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式移动jQuery UI .sortable()中的元素 - How to move elements in a jQuery UI .sortable() programatically 通过jQuery ui sortable()与多个元素一起移动 - Move with multiple elements by jQuery ui sortable() 如何在没有鼠标的情况下移动JQuery可拖动元素 - How do I move JQuery draggable element without mouse 如何在jQuery UI可排序列表中停止可排序的项目? - How do I stop an item being sortable in a jquery UI sortable list? 如何更改jQuery UI Sortable(连接列表)演示,以便实际上只有一个列表是可排序的? - How do I alter the jQuery UI Sortable (connected lists) demo such that only one list is actually sortable? 如何在拖动时将JQuery UI Sortable项目放置在鼠标光标处? - How do I position JQuery UI Sortable item at mouse cursor while dragging? jQuery UI可排序以在发生冲突时“交换”列表元素 - Jquery UI Sortable to “swap” list elements on collision jQuery sortable()-将元素移动到连接列表之前的第一个不可排序元素 - jQuery sortable() - move elements to connected list before first element that is not sortable 没有jQuery UI的jQuery Sortable - jQuery Sortable without jQuery UI Jquery UI可拖动/可排序而无需按住鼠标按钮 - Jquery UI Draggable/Sortable without holding the mouse button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM