我遇到的代码问题是限制听到声音的次数,事实是Firefox在按下按钮三次时会听到声音,但是在按下按钮时Chrome不听
有什么问题?
var escolta = document.getElementById('sonido');
var quantitat = 2
var r = 0
function maximrepeticions(){
if(r<=quantitat){
sonido.play();
r++;
}else{
sonido.pause();
}
}
var escolta = document.getElementById('sonido');
var quantitat1 = 2
var r1 = 0
function maximrepeticions1(){
if(r1<=quantitat1){
sonido.play();
r1++;
}else{
sonido.pause();
}
}
var escolta = document.getElementById('sonido');
var quantitat2 = 2
var r2 = 0
function maximrepeticions2(){
if(r2<=quantitat2){
sonido.play();
r2++;
}else{
sonido.pause();
}
}
<td align="center">
<audio id="sonido" src="file:///C:/Users/ACME/Desktop/Triar/sound/bang.mp3">
</audio>
<center><button onclick="maximrepeticions()">
Listen first example</button></center>
<br><br>
<center><button onclick="storage_validation()">
Input the number to the correct image</button></center>
</td>