小编use*_*953的帖子

在IE/FireFox中工作但不在chrome中的HTML代码

这是一个非常简单的代码,我想尝试并运行,因为我想学习一些JavaScript基础知识.该代码适用于Internet Explorer和Firefox,但不适用于chrome.我觉得我必须错过一些非常愚蠢的东西.

var frame = 2;
function animate(){

if(frame == 1){
    frame = frame + 1;
    document.getElementById("animate").src = "walking1.png";
}
else if (frame == 2){
    frame = frame + 1;
    document.getElementById("animate").src = "walking2.png";
}
else{
    frame = 1;
    document.getElementById("animate").src = "walking3.png";
}
}
Run Code Online (Sandbox Code Playgroud)
<p> clicking the button will change the image.</p>

<img id="animate" src="walking1.png">

<button onclick="animate()">click me to animate</button>
Run Code Online (Sandbox Code Playgroud)

使用的图片保存在同一个文件夹中.

html javascript

3
推荐指数
1
解决办法
96
查看次数

标签 统计

html ×1

javascript ×1