2016-07-07 105 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'/>