Play Audio On Click Using Elementor With A Button, Icon Or Image

Share on facebook
Facebook
Share on twitter
Twitter
Share on reddit
Reddit
Share on whatsapp
WhatsApp

Source Code

				
					<script>
let audioButton = document.querySelector('.audio-button');   // <-- Change CSS Class Here
       audioButton.addEventListener('click', function(){
        var audio = document.getElementById("audio");
        
         if (audio.paused) {
            audio.play();
        }else{
            audio.pause();
            // audio.currentTime = 0
        }
      });
    </script>
    
    <audio id="audio" src=""></audio>
				
			
Subscribe
Notify of
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Edouard
5 months ago

Super ! thank you… was looking exactly for a such easy way to launch a music on a web site page by clicking on a button ! or image it everything !! It’s working perfectly… so easy nd simple…. super .. thank you

Ash
13 hours ago
Awaiting for approval

Hello! Thanks for your solution. It works great for 1 button. But is there any solution to use this in 2 buttons? (And keep on/off audio by click the buttons)

More to explorer

Elementor GSAP Text Split Reveal

https://youtu.be/ml7Mf5MRgTw Step 1 Add the class name text_reveal to the headline element Make sure the headline element HTML Tag is set to

2
0
Would love your thoughts, please comment.x
()
x

45 Minute Wordpress Support

Get your Wordpress questions answered and your Wordpress issues resolved.