嗨,我有这个JavaScript的Javascript改变IMG不工作
<script>
function showSurpriseImage() {
var x = document.createElement("IMG");
x.setAttribute("id", "boxmm");
x.setAttribute("class", "boxmm");
x.setAttribute("src", "images/mese.gif");
x.setAttribute("onclick", "showSurpriseImage2();PlayedSound2();");
document.getElementById("surprise").appendChild(x);
}
</script>
<script>
function showSurpriseImage2() {
var x = document.getElementById("boxmm");
x.setAttribute("src", "images/source.gif");
x.setAttribute("onclick", "showSurpriseImage3();PlayedSound2()");
x.setAttribute("class", "boxml");
x.setAttribute("id", "boxml");
}
</script>
<script>
function showSurpriseImage3() {
var x = document.getElementById("boxml");
x.setAttribute("src", "images/source.gif");
x.setAttribute("onclick", "showSurpriseImage3();PlayedSound2()");
x.setAttribute("class", "boxml");
x.setAttribute("id", "boxml");
}
</script>
其点击的是IMG后更改GIF,但是当我按上的onclick功能showSurpriseImage2()img标签按钮{它不会发挥source.gif但是再次使用第一个GIF,然后它会播放source.gif。我无法找到问题。由于
HTML 这是滋生第一GIF(showSurpriseImage)
<a class="boxmb" href="#section2"><img class="boxmb" id="boxmb" id="togglee"
src="images/box1.png" id="image1"
onclick="showButton();diffImage(this);showSurpriseImage();PlaySound();" >
</a>
The site is not responsive yet so you wont see it properly
http://americafulfillment.com/#section2
粘贴HTML以及 –
请让你的代码片段或发布的jsfiddle ... – void
http://americafulfillment.com/#section2这里我的网站链接 –