jquery使用animate方法实现控制元素移动
更新时间:2015年03月27日 09:39:06 作者:上大王
这篇文章主要介绍了jquery使用animate方法实现控制元素移动,涉及jQuery中animate方法的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了jquery使用animate方法实现控制元素移动。分享给大家供大家参考。具体分析如下:
通过jquery的animate方法控制元素移动,这里需要将元素的位置定义为relative, fixed, 或者 absolute!
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left:'250px'});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position,
and cannot be moved. To manipulate the position,
remember to first set the CSS position property
of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;
height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
相关文章
jQuery EasyUI tree 使用拖拽时遇到的错误小结
在我使用tree拖拽时总是失败,控制台输出了很多错误。经过问题跟踪分析最终找到的错误原因,下面小编给大家分享下,感兴趣的朋友参考下2016-10-10
jquery 获取 outerHtml 包含当前节点本身的代码
jQuery.html() 是获取当前节点下的html代码,并不包含当前节点本身的代码,后来实验发现有一个jQuery的一个方法可以解决2014-10-10
jQuery实现html table行Tr的复制、删除、计算功能
这篇文章主要介绍了jQuery实现html table行Tr的复制、删除、计算功能,涉及jQuery针对table表格的常见复制、添加、删除与计算行数等简单操作技巧,需要的朋友可以参考下2017-07-07


最新评论