How to create onclick music ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How to create onclick music ?

I want to make a webpage in which if I click on screen the audio starts playing automatically however, the audio control should not be visible. Can you tell the code ?

16th Jun 2021, 4:50 AM
Harsh
Harsh - avatar
3 Answers
+ 14
Here's the example. I used a button. You can try using body instead. https://code.sololearn.com/WYQWv9z9cndF/?ref=app
16th Jun 2021, 5:29 AM
Igor Makarsky
Igor Makarsky - avatar
+ 14
https://code.sololearn.com/WxPVZz819g1O/?ref=app
16th Jun 2021, 7:38 AM
Simba
Simba - avatar
0
You are not forced to add controls attribute for the audio. Add the onclick event to the body tag. You can use the play fumction [.play()] to play the song; that's so easy
16th Jun 2021, 3:42 PM
🇮🇱 Radin Masiha 🇮🇱
🇮🇱 Radin Masiha 🇮🇱 - avatar