我有一個播放和暫停按鈕,我希望播放變成一個暫停按鈕,當我點擊它。我的我的播放和暫停按鈕準備好在我的CSS和我的HTML頭部的JavaScript。Javascript顯示/隱藏播放/暫停按鈕
但是,當我點擊播放按鈕時,暫停一個將不會顯示。
<script>
$('#play').on('click', function(event) {
currentPlayingTrack.play();
$('#pause').show();
$('#play').hide();
});
$('#pause').on('click', function(event) {
currentPlayingTrack.pause();
$('#pause').hide();
$('#play').show();
});
</script>
#play, #pause {
width:80px;
height: 80px;
background: transparent;
position: relative;
margin-top: 10px;
display: block;
}
#play {
width: 0;
height: 0;
border-left: 30px solid white;
border-right: 30px solid transparent;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
position: absolute;
content: "";
top: 10px;
left: 25px;
}
#pause:before {
width: 10px;
height: 60px;
background: white;
position: absolute;
content: "";
top: 10px;
left: 25px;
}
#pause:after {
width: 10px;
height: 60px;
background: white;
position: absolute;
content: "";
top: 10px;
right: 25px;
}
<div>
<a href="#" id="play"></a>
<a href="#" id="pause" style="display: none;"></a>
</div>
我在做什麼錯?
正確?玩鏈接隱藏? – nnnnnn
它的工作,我發現的唯一錯誤是'currentPlayingTrack未定義'。小提琴在這裏https://jsfiddle.net/flyinggambit/qju6rjps/ –