この記事では、円形の動きを作成するJS制御層の方法について説明します。次のように、参照のために共有してください。
<!doctype html public " - // w3c // dtd html 4.01 // en" "http://www.w3.org/tr/html4/strict.dtd"> <hhtml> <head>< meta http-iv =" content-type "content-type"> html; motion </title> <script type = "text/javascript"> window.onload = function(){var ctrlbtn = $ id( "ctrl"); var ismove = true; om = null; ctrlbtn.onclick = function(){if(ismove){movebycircle(); } else {clearInterval(om); } ismove =!ismove; }} function moveBycircle(){var bacl = parseint($ id( "clockbac")。style.left); var bact = parseint($ id( "ClockBac")。style.top); var bacw = parseint($ id( "ClockBac")。style.width); var bach = parseint($ id( "ClockBac")。style.height); var initl = BACL+BACW/2; var initt = bact+bach/2; var step = 0; var r = 65; $ id( "tt")。style.left = initl+"px"; $ id( "tt")。style.top = initt+"px"; var l = parseint($ id( "tt")。style.left); var t = parseint($ id( "tt")。style.top); om = window.setinterval(function(){if(step == 360){step = 1;} $ id( "tt")。left.left =(l + r * math.sin(step)) + "px"; $ id( "tt") d.gethours(); } function $ id(id){return document.getElementById(id); } </script> </head> <body> <div id = "tt" style = "width:10px; height:10px; background:red; position:aspolute; top:105px;左:130px;"> div> <入力タイプ= "ボタン" button "id =" ctrl "style =" width:100px; " id = "clockbac" style = "width:200px; height:200px; top:100px; left:100px; position:absolute; z-index:-999"/> </body> </html>JavaScript関連のコンテンツの詳細については、このサイトのトピックをご覧ください:「JavaScriptの切り替え効果とテクニックの要約」、「JavaScript検索アルゴリズムスキルの要約」、「JavaScriptアニメーション効果とテクニックの概要」、「Javascriptエラー、および「Javascriptデータ構造」の概要」の概要の要約の要約をご覧ください。 JavaScriptトラバーサルアルゴリズムとテクニック」、および「JavaScriptの数学的操作の使用法の要約」
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。