JSFiddle - React, Tailwind, and code Playground

by André Albson

HTML

<body>
    <button id="play">Play</button>
    <button id="pause">Stop</button>
</body>

JavaScript

$(document).ready(function() {
    var audioElement = document.createElement('audio');
    audioElement.setAttribute('src', 'http://www.soundjay.com/misc/sounds/bell-ringing-01.mp3');
    
    audioElement.addEventListener('ended', function() {
        this.currentTime = 0;
        this.play();
    }, false);
    
    $('#play').click(function() {
        audioElement.play();
    });
    
    $('#pause').click(function() {
        audioElement.pause();
    });
});