0
私はHTMLページに4つのdiv要素を持っています。ページの読み込みを開始する必要があります。ユーザーがクリックすると移動中に最初のdivでサイズを変更する必要があります。 div要素はページの読み込みを開始する必要があり、最初のdivはユーザーがクリックするとサイズを変更する必要があります。私は、進行中のアニメーションをクリックイベントと組み合わせる方法を知らない。ここにコード:jQueryで要素の「クリック」イベントとアニメーションを同時に呼び出す方法は?
HTML
<html>
<head>
<title>jQuery Animation</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div id="id_1" style="background:purple; width:100px; height:100px; border-radius:50%; position:absolute; z-index:1000;"></div>
<div id="id_2" style="background:blue; width:100px; height:100px; position:absolute;"></div>
<div id="id_3" style="background:yellow; width:300px; height:100px;position:absolute;"></div>
<div id="id_4" style="background:green; width:300px; height:100px; border-radius:50%;position:relative; float:right;"></div>
</body>
<script src="script2.js"></script>
</html>
jQuery
$(document).ready(function(){
$("#id_1").animate({left:700, top: 500}, 10000).animate({left:0},10000).animate({top:0},10000);
$("#id_2").animate({left:800}, 10000).animate({top:400},10000).animate({left:0},10000).animate({top:0},10000);
$("#id_3").animate({top: 500}, 10000).animate({left:400},10000).animate({left:0, top:0},10000);
$("#id_4").animate({top: 500, right: 500}, 10000).animate({top:700},2000).animate({right:800},2000).animate({top:0, right:0},10000);
});`enter code here`
$("#id_1").click(function(){
$("#id_1").animate({
"width":"500px",
"height":"500px"
});
});
私は( 'クリック'、機能(){ $(この)の.css({ 幅に$( "#のID_1")でそれを行うために管理:「500pxなど。 "、 高さ:" 500px " }、2500); }); CSSではなく何らかの方法でアニメーションで行うことができます –
回答が編集されています、確認してください –