jquery ui droppable用不了
photo是图片的div,trash是回收站的div引入ui插件后,用droppable应该是有提示的,结果没有。打完droppable后也没有变颜色。draggable...
photo是图片的div , trash是回收站的div 引入ui插件后,用droppable应该是有提示的,结果没有。打完droppable后也没有变颜色。draggable方法是有提示的。
展开
1个回答
展开全部
jQuery Draggable和Droppable实现拖拽功能的实现方法如下:
1、Draggable实现方法:
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>jQuery UI Draggable - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <style> #draggable { width: 150px; height: 150px; padding: 0.5em; } </style> <script> $(function() { $( "#draggable" ).draggable(); }); </script></head><body> <div id="draggable" class="ui-widget-content"> <p>Drag me around</p></div> </body></html>
运行效果:
用户可以随意拖拽上图中的小方块
2、Droppable的实现方法:
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>jQuery UI Droppable - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <style> #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; } #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; } </style> <script> $(function() { $( "#draggable" ).draggable(); $( "#droppable" ).droppable({ drop: function( event, ui ) { $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped!" ); } }); }); </script></head><body> <div id="draggable" class="ui-widget-content"> <p>Drag me to my target</p></div> <div id="droppable" class="ui-widget-header"> <p>Drop here</p></div> </body></html>
运行效果:
a.拖拽前如下:
b.拖拽后:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询