jQueryのお勉強。
要素(何を):$(“#circle”)
イベント(いつ):.on(“click”)
メソッド(どうする):.animate()
↓サンプル
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script> $(function(){ $("#circle").on("click", function(){ $(this).animate({ "marginLeft": "700px", "marginTop": "150px", "border-radius": "20px" }); }); }); </script> <style type="text/css"> div#circle{ width: 200px; height: 200px; background-color: blue; border-radius: 100px; } </style> </head> <body> <p>クリックすると、右下へ移動します。</p> <div id="circle"></div> </body> </html>
コメント