ホームページ  >  記事  >  ウェブフロントエンド  >  jquery は animate メソッドを使用して要素 motion_jquery を制御します

jquery は animate メソッドを使用して要素 motion_jquery を制御します

WBOY
WBOYオリジナル
2016-05-16 16:07:211526ブラウズ

この記事の例では、jquery が animate メソッドを使用して要素の動きを制御する方法を説明します。皆さんの参考に共有してください。具体的な分析は次のとおりです。

jquery の animate メソッドを使用して要素の動きを制御します。ここでは、要素の位置を相対、固定、または絶対として定義する必要があります。

<!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 プログラミングに役立つことを願っています。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。