Javascript 添加文本框并使用旋转字符串设置动画

Javascript 添加文本框并使用旋转字符串设置动画,javascript,Javascript,大家好,我们的老师要求我们添加输入类型=文本,并使用带有以下代码的旋转字符串设置动画: <html> <head> <title>Javascript Basic Animation</title> <script type="text/javascript"> function animate_string(id) { var element = document.getEle

大家好,我们的老师要求我们添加输入类型=文本,并使用带有以下代码的旋转字符串设置动画:

 <html>
    <head>
    <title>Javascript Basic Animation</title>
    <script type="text/javascript">
    function animate_string(id)
    {
        var element = document.getElementById(id);
        var textNode = element.childNodes[0]; // assuming no other children
        var text = textNode.data;
    setInterval (function ()
    {
    text = text[text.length - 1] + text.substring (0, text.length - 1);
    textNode.data = text;
    }, 100);
    }
    </script>
    </head>
    <body onload="animate_string('target')">
    <pre>
    Write a Javascript program to rotate the string 'HELLO WORLD'
    in right direction by periodically removing one letter from
    the end of the string and attaching it to the front.
    </pre>
    <font size="21">
    <pre id="target">HELLO WORLD</pre>
    </font>
    </body>
    </html>
但我不知道怎么做。请帮忙,谢谢。

试试这个:


您只需要调用animate_字符串'id of element here';来自脚本。

在这里获得帮助的最佳方法是首先尝试一些东西。如果你陷入困境,做一些研究,尝试自己解决问题,然后再问一个关于你尝试的具体问题。在没有展示研究成果的情况下要求完整解决方案的问题通常会被否决和关闭。
s = "hello world" ;
l = strlen(s) ;

tmp = substr(s, 1, l-2) + substr(s, 0, 1) ;
s = tmp