How to play an audio file on a button click using Jquery or JavaScript?

Today I will be showing you How to play an audio file on a button click using jQuery or JavaScript.

//This is the Jquery / JavaScript code you need to use
jQuery(document).ready(function($) {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'https://shutupandlistentoyourself.com/wp-content/uploads/2021/05/audio.mp3');
 $('#playAudioBtn').click(function(e) {
	e.preventDefault();
	if($('#playAudioBtn').hasClass("audio_playing")){
		audioElement.pause();
		$('#playAudioBtn').removeClass("audio_playing");
		$('#playAudioBtn .elementor-button-text').text("PLAY AUDIO");
	} else{ 
		audioElement.play();
		$('#playAudioBtn .elementor-button-text').text("PAUSE AUDIO");	
		$('#playAudioBtn').addClass("audio_playing"); 
	}
});
});