Since there are several things you handle when you click “play” on an audio element, it would be better idea to create a function to handle that. In that function you can do stuff like add the “playing” class, as i see is part of your app design, ofc make the element play and to follow your desire, to make sure no other element is currently playing(stop it, if there is such). Its might be easy to identify such element by targeting the “playing” class with query selector and pause/stop the audio of that element, as well as remove the class off it(assuming only one element is to be playing at any time). You should also be careful of the order in which you run the different actions. Have it clearly thought in your head and even write down on a note, whats to be done after what. For example- look if there is element “playing”, stop/pause that element and remove the class, add the class to the current element that has been clicked, make the element play.