我用下面这种方式拖动层,但是我想控制拖动范围只在id为indexDiv的div中拖动,请问jquery高手怎么做
$("#shopIndex-map").draggable({axis:"x"});shopIndex-map这是我要拖动的div的id...
$( "#shopIndex-map" ).draggable({ axis: "x" }); shopIndex-map这是我要拖动的div的id
展开
2个回答
展开全部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false }); //容器拖动
})
</script>
</head>
<body>
<div id="containment-wrapper" style="width:200px; height:300px; background-color:Gray;">
<div id="draggable3" style="width:80px; height:80px; background-color:Red">
我只能在容器里拖动
</div>
</div>
</body>
</html>
http://www.jb51.net/jiaoben/24271.html //这里下载,有实例和代码,自己去看看
<head>
<title></title>
<script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false }); //容器拖动
})
</script>
</head>
<body>
<div id="containment-wrapper" style="width:200px; height:300px; background-color:Gray;">
<div id="draggable3" style="width:80px; height:80px; background-color:Red">
我只能在容器里拖动
</div>
</div>
</body>
</html>
http://www.jb51.net/jiaoben/24271.html //这里下载,有实例和代码,自己去看看
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询