admin管理员组

文章数量:1301596

I have an unordered list <ul> with list items <li> which I'd like to be able to "reorder" via dragging. I'm using jQuery. How could I acplish this? I tried hooking into the click event but I can't get the drag to work right (I want the other <li> elements to move out of the way once I drag an <li> element over a suitable spot so the user can see where it would end up).

Help?

I have an unordered list <ul> with list items <li> which I'd like to be able to "reorder" via dragging. I'm using jQuery. How could I acplish this? I tried hooking into the click event but I can't get the drag to work right (I want the other <li> elements to move out of the way once I drag an <li> element over a suitable spot so the user can see where it would end up).

Help?

Share asked Jul 25, 2010 at 19:03 AlexAlex 77.4k91 gold badges265 silver badges350 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

If you don't need to invent the wheel:

http://jqueryui./demos/sortable

Have you considered jQuery UI's droppable/draggable functionality?

Here's a link to a ul demo.

http://jqueryui./demos/draggable/#sortable

本文标签: jQueryJavaScript Reorder Unordered List via DraggingStack Overflow