我只是在学习 JS,以便我可以拥有具有翻转状态和音效的按钮。我做得很好,直到我厌倦了添加额外的按钮,这导致我失去了翻转状态。
你可以在这里看到我的一个按钮的例子:http ://www.ultralaboratories.com/sound1.html
这里有两个按钮:http ://www.ultralaboratories.com/sound2.html
为简单起见,我使用了完全相同的按钮两次,但完成后会有 5 个独特的按钮。
有什么想法吗?谢谢!
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
title>Untitled Document</title>
<audio id="audio_element" src="sound.mp3"></audio>
<script>
var audio = document.getElementById("audio_element");
audio.volume = 0;
audio.play();
function playAudio() {
audio.currentTime = 0.01;
audio.volume = 1;
audio.play();
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide from non JavaScript Browsers
Rollimage = new Array()
Rollimage[0]= new Image(156,311)
Rollimage[0].src = "/Images/Banner/e.up.jpg"
Rollimage[1] = new Image(156,311)
Rollimage[1].src = "/Images/Banner/e.over.jpg"
function SwapOut(){
document.element.src = Rollimage[1].src;
return true;
}
function SwapBack(){
document.element.src = Rollimage[0].src;
return true;
}
// - stop hiding -->
</SCRIPT>
</head>
<body>
<div onmouseover="playAudio()">
<P align="center">
<A HREF="http://www.joemaller.com/" onmouseover="SwapOut()" onmouseout="SwapBack()"> <IMG SRC="/Images/Banner/e.up.jpg" NAME="element" WIDTH=156 HEIGHT=311 BORDER=0> </A>
<A HREF="http://www.joemaller.com/" onmouseover="SwapOut()" onmouseout="SwapBack()"> <IMG SRC="/Images/Banner/e.up.jpg" NAME="element" WIDTH=156 HEIGHT=311 BORDER=0> </A>
</P>
</div>