嗨,我有這個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這裏我的網站鏈接 –