Answer the question
In order to leave comments, you need to log in
How to play an audio file on button click using the audio tag?
There is the following code:
start autoplay
$('.startMusic').on('click', function(){
$('.music').attr({
'autoplay': true,
'paused': false,
'controls' : true
});
});
When you click on the button, the music should play, but this does not happen, why?
What else have I not learned? It seems that I looked through all the properties of the audio object, but did not find the reason for launching the file.
Need help...
Answer the question
In order to leave comments, you need to log in
$('.startMusic').on('click', function(){
$('.music')[0].play()
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question