jQuery拖放ul和li元素 [英] jQuery drag and drop ul and li elements

查看:85
本文介绍了jQuery拖放ul和li元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一方面,我得到了<ul><li>的列表. <ul><li>元素应拖放.目标是divspan.我该如何开始?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆