继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

jQuery UI 拖动(Draggable)

android开发学习视频
关注TA
已关注
手记 304
粉丝 52
获赞 322

定义和用法

只有当光标在 draggable 上指定部分时才允许拖拽。使用 handle 选项来指定用于拖拽对象的元素(或元素组)的 jQuery 选择器或者当光标在 draggable 内指定元素(或元素组)上时不允许拖拽。使用 cancel选项来指定取消拖拽功能的 jQuery 选择器


示例

<!DOCTYPE html><html><head>	<meta charset="utf-8">	<meta http-equiv="X-UA-Compatible" content="IE=edge">	<title>jQuery UI 拖动(Draggable) - Handles和Cancel</title>	<link rel="stylesheet" href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css">	<style>		#draggable1, #draggable2 { 			width: 200px; 			height: 200px; 			padding: 0.5em; 			float: left; 			margin: 0 10px 10px 0; 		}  		#draggable p {   			cursor: move;   		}	</style></head><body>	<div id="draggable1" class="ui-widget-content">	  	<p class="ui-widget-header">您只可以在这个范围内拖拽我</p>	</div> 	<div id="draggable2" class="ui-widget-content">	  	<p>您可以把我向四周拖拽</p>	  	<p class="ui-widget-header">但是您不可以在这个范围内拖拽我</p>	</div>	<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js" type="text/javascript" ></script>	<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>	<script>		$(function(){			$("#draggable1").draggable({				handle:"p"			});			$("#draggable2").draggable({				cancel:"p.ui-widget-header"			});		});	</script></body></html>


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP