JSFiddle - React, Tailwind, and code Playground

by Sean Wessell

HTML

<a href="#" id="toggleSong">Change</a>

<audio id="audio1" controls autoplay src="http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2007.mp3" type="audio/mpeg"></audio>

JavaScript

$.fn.togglePropValue = function (name, vals) {
    var toggles = vals.split(' ');
    if (toggles.length > 1) {
        if (this.prop(name) == toggles[0]) {
            this.prop(name, toggles[1]);
        } else if (this.prop(name) == toggles[1])

        {
            this.prop(name, toggles[0]);
        }
    }
    return this;
}

$('#toggleSong').click(function () {
    $('#audio1').togglePropValue('src', 'http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2007.mp3 http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2009.mp3').trigger('play');
});