Streaming live at 10am (PST)

How to add second button playing audio on click in Webflow (With some Javascript)

How to add second button playing audio on click in Webflow (With some Javascript)

**Not work second button
6-9-2021 11-05-45 AM


source : Playing Audio On Click in Webflow (With some Javascript) | Quick Tip - YouTube

Hello, can you please provide your website so I can help out

Thanks

Hi, PixZen
Thankyou

https://testaudio1.webflow.io/

<audio id="audio" src="a1.mp3?1=1"></audio>
<script>
const audioElement = document.getElementById('audio');
const playSun = document.querySelector('.play-sun');
playSun.addEventListener('click', function() {
	audioElement.play();
});
</script>

Hello FMD,

I tried all sorts of ways to play this, I guess audio tags only work when they’re referencing local audio files , not online through a link.

image

I’d suggest downloading the audio file and referencing it in the src