Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按钮点击事件获胜';t火_Javascript_Html_Button_Onclick - Fatal编程技术网

Javascript 按钮点击事件获胜';t火

Javascript 按钮点击事件获胜';t火,javascript,html,button,onclick,Javascript,Html,Button,Onclick,请帮忙。任务是:“编写一个JavaScript程序,通过周期性地从字符串末尾删除一个字母并将其附加到前面,以正确的方向旋转字符串‘w3resource’。” 函数moveIt(){ var元素=document.getElementById(“目标”); var textNode=element.childNodes[0]; var text=textNode.nodeValue; setInterval(函数(){ text=text[text.length-1]+text.substri

请帮忙。任务是:“编写一个JavaScript程序,通过周期性地从字符串末尾删除一个字母并将其附加到前面,以正确的方向旋转字符串‘w3resource’。”


函数moveIt(){
var元素=document.getElementById(“目标”);
var textNode=element.childNodes[0];
var text=textNode.nodeValue;
setInterval(函数(){
text=text[text.length-1]+text.substring(0,text.length-1);
textNode.nodeValue=文本;
}, 500);
}

单击以设置动画
w3resource


DOM已经使用了名称
animate
。只需更改函数的名称。它会起作用的

并且不需要设置函数的参数,因为您是通过id获取元素的

函数moveIt(){
var元素=document.getElementById(“目标”);
var textNode=element.childNodes[0];
var text=textNode.nodeValue;
setInterval(函数(){
text=text[text.length-1]+text.substring(0,text.length-1);
textNode.nodeValue=文本;
}, 500);
}

单击以设置动画
w3resource


DOM已经使用了名称
animate
。只需更改函数的名称。它会起作用的

并且不需要设置函数的参数,因为您是通过id获取元素的

函数moveIt(){
var元素=document.getElementById(“目标”);
var textNode=element.childNodes[0];
var text=textNode.nodeValue;
setInterval(函数(){
text=text[text.length-1]+text.substring(0,text.length-1);
textNode.nodeValue=文本;
}, 500);
}

单击以设置动画
w3resource


我认为您调用的是保留的方法名,而且您使用的是字符串值而不是变量。更改为
foo
,工作正常


单击以设置动画
w3resource

功能foo(目标){ var元素=document.getElementById(目标); var textNode=element.childNodes[0]; var text=textNode.nodeValue; setInterval(函数(){ text=text[text.length-1]+text.substring(0,text.length-1); textNode.nodeValue=文本; }, 500); }
我认为您调用的是保留的方法名,而且您使用的是字符串值而不是变量。更改为
foo
,工作正常


单击以设置动画
w3resource

功能foo(目标){ var元素=document.getElementById(目标); var textNode=element.childNodes[0]; var text=textNode.nodeValue; setInterval(函数(){ text=text[text.length-1]+text.substring(0,text.length-1); textNode.nodeValue=文本; }, 500); }
非常感谢各位!我会小心使用变量名。非常感谢大家!我会小心使用变量名。