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 简短搞笑的虎年祝福语