jquery使用animate方法实现控制元素移动
本文实例讲述了jquery使用animate方法实现控制元素移动。分享给大家供大家参考。具体分析如下:
通过jquery的animate方法控制元素移动,这里需要将元素的位置定义为relative,fixed,或者absolute!
<!DOCTYPEhtml>
<html>
<head>
<scriptsrc="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left:'250px'});
});
});
</script>
</head>
<body>
<button>StartAnimation</button>
<p>Bydefault,allHTMLelementshaveastaticposition,
andcannotbemoved.Tomanipulatetheposition,
remembertofirstsettheCSSpositionproperty
oftheelementtorelative,fixed,orabsolute!</p>
<divstyle="background:#98bf21;
height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志