脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-jQuery拖到效果,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。 &nbs
p; <style ty
PE="text/css">
img {
width: 100px;
h
eight: 100px;
}
#myp
{
width: 500px;
height: 300px;
border: solid 1px
red;
}
#myp2
{
width: 500px;
height: 300px;
border: solid 1px red;
}
</style>
<script src="js/
jquery1.7.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery.ui.widget.js" type="text/javascript"></script>
<script src="js/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="js/jquery.ui.
Draggable.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('img').draggable({
//axis:'y'//规定只能沿y轴拖动
//cont
ainment: '#myp' //规定拖动的区域
//containment: 'parent' //父容器的另一种写法
//containment: '#myp2' //规定的拖动区域可以不是元素的父容器
//grid:[50,50]
opac
ITy: 0.3, //设置拖动时的透明度
//
revert: true,
start: function () {
$('#myp2').text('
开始移动了');
},
stop: function () {
$('#myp2').text('停了');
},
drag: function () {
//$('#myp2').text('一直在
努力');
$('#myp2').text($('img').offset().left + "," + $('img').offset().top);
}
});
//设置一个元素的
距离浏览器左边缘和上边缘的距离(横坐标和纵坐标)
$('#Butto
n1').click(function () {
$('img').offset({
left: 200,
top: 200
});
})
})
</script>
</head>
<body>
<p id="
;myp">
<img src="images/2.
jpg" /></p>
<p id="myp2">
<input id="Button1" type="button" value="button" />
</p>
</body>
觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!
脚本宝典总结
以上是脚本宝典为你收集整理的javascript代码实例教程-jQuery拖到效果全部内容,希望文章能够帮你解决javascript代码实例教程-jQuery拖到效果所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。