Este artículo describe el método de la capa de control JS que realiza el movimiento circular. Compártelo para su referencia, como sigue:
<! DocType html public "-// w3c // dtd html 4.01 // en" "http://www.w3.org/tr/html4/strict.dtd"><html><head><meta http-equiv =" contenido "contenido =" text/html; charset = Utf-8 movimiento </title> <script type = "text/javaScript"> window.onload = function () {var ctrlbtn = $ id ("ctrl"); var isMove = true; om = nulo; ctrlbtn.onclick = function () {if (isMove) {MoveByCircle (); } else {ClearInterval (om); } isMove =! IsMove; }} función MoveByCircle () {var bacl = parseInt ($ id ("relojbac"). style.left); var bact = parseInt ($ id ("relojbac"). style.top); var bacw = parseint ($ id ("relojbac"). style.width); var bach = parseInt ($ id ("relojbac"). style.height); var initl = BACL+BACW/2; var initt = bact+bach/2; Paso var = 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"). style.left = (l + r * math.sin (step) + "px"; $ id ("tt"). style.top = (t - r * math.cos (step)) + "px"; step + = 3.14/30; vAR d date (); d.gethours (); } function $ id (id) {return document.getElementById (id); } </script> </head> <body> <div id = "tt" style = "width: 10px; Height: 10px; fondos: rojo; posición: absoluto; top: 105px; izquierda: 130px;"> </div> <input type = "button" id = "ctrl" style = "width: 100px; posicion: absoluta;"/> <img src = "/" ctl ". id = "Clockbac" style = "Ancho: 200px; altura: 200px; arriba: 100px; izquierda: 100px; posición: absoluto; z-odex: -999"/> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript Algoritmos y técnicas de recorrido ", y" Resumen del uso de operaciones matemáticas de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.