To play a sound when a button is clicked in WordPress Brizy
I asked chat gpt for this question they suggest me a anwer but ı need help again.
<button id="playSoundButton">Click to Play Sound</button>
<audio id="audioElement"> <source src="URL_OF_YOUR_SOUND_FILE" type="audio/mpeg"> Your browser does not support the audio element. </audio>
<script> document.getElementById('playSoundButton').addEventListener('click', function() { var audio = document.getElementById('audioElement'); audio.play(); }); </script>
how can ı activate this code to my brizy button ?
-
Hi Ahmet,
Thank you for contacting us.
Custom scripts should work using the Embed element. But first you need to upload your audio file into WordPress Media and copy the URL, so you can include it in the custom script, this is demonstrated in this screencast – https://youtu.be/gaqq9h-A5Xw.
I hope this helps.
Best regards,
Ariel H.0 -
Hello,
What I'm asking is, how can we activate this sound file on an existing brizy button?
In this, we add the script code to the footer. Then we learn the id number of the brizy button by saying inspect on our website. When we add this id name to the script code, the code works.0 -
Hi Ahmet,
Sorry about that, you can put the button ID "playSoundButton" in a button and add the rest of the script in the Embed element as shown on this screencast - https://youtu.be/jOrkAeTnGjE
If you have any further questions, please let us know.
Best regards,
Ariel H.0 -
yes but script code not working on <head> codes ı can copy paste footer then ıt ıs working and ı created an awesome button click sound.
0
Please sign in to leave a comment.
Comments
4 comments