jQuery拖放ul和li元素 [英] jQuery drag and drop ul and li elements
问题描述
一方面,我得到了<ul>
和<li>
的列表. <ul>
和<li>
元素应拖放.目标是div
或span
.我该如何开始?
On one hand I got list of <ul>
and <li>
. The <ul>
and <li>
elements should be dragged and droped. The target is a div
or span
. How could I get started?
推荐答案
基本上,您的可拖动对象将是<li>
元素,而您的可放置对象将是<div>
或<span>
或两者.为可拖动和可放置设置必要的选项.然后处理可拖动对象的拖动事件和可放置对象的放置事件,以执行任何自定义功能.使用droppable(可以是选择器或函数)的accept选项来验证drop元素.这是必要的文档:
Basically your draggables would be the <li>
elements and your droppable will be the <div>
or <span>
or both. Set the necessary options for both the draggable and the droppable. Afterwards handle the drag event of the draggable and the drop event of the droppable in order to perform any custom functionality. Validate drop elements with the accept option of the droppable (it's either a selector or a function). Here is the necessary documentation:
可拖动: http://jqueryui.com/demos/draggable/
可投放: http://jqueryui.com/demos/droppable/
jsFillde:小提琴
jsFillde: fiddle
这篇关于jQuery拖放ul和li元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!