2016-07-07 95 views
-1

我的代碼:https://jsfiddle.net/5bj8suxj/我試圖讓暫停和播放按鈕的工作交替

有人可以幫助我。播放按鈕有效,但暫停不起作用。你按播放它的作品,但按暫停沒有效果。

<div style="display:block; cursor: pointer; width: 50px; height:50px; background-color:#00ffff;"> 

<button style="cursor: pointer; font-family:Tahoma; font-weight: bold;font-size:14px; background-color:#00ffff;color:blue;padding: 0px 0px 0px 0px;" 
onclick="document.getElementById('player').play()">Play</button> 

</div></div> 

<div id="myObj5h" style="display: none;"> 

<div style="display:block;width: 50px; height:50px; background-color:orange;"> 

<button style="cursor: pointer; font-family:Tahoma; font-weight: bold;font-size:14px; background-color:orange;color:blue;padding: 0px 0px 0px 0px;" 
onclick="document.getElementById('player').Pause()">Pause</button> 

<audio id="player" style="display:none;"> 
<source src='http://hi5.1980s.fm/;' type='audio/mpeg'/> 
</audio> 
</div></div> 
+1

將'Pause()'改爲'pause()'... – makshh

回答

0

你的代碼有兩個問題。

第一個問題是暫停按鈕...暫停功能應該是小寫:暫停,而不是暫停() 第二個問題是在結構中......音頻元素應該在div#myObj5h之外。

e.g

... http://hi5.1980s.fm/;」 type ='audio/mpeg'/>