Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Michele Smiraglia](https://uploads.teamtreehouse.com/production/profile-photos/3081962/micro_11924237_474460926065917_1443848090266930120_n.jpg)
Michele Smiraglia
6,509 PointsOverlapping audio...
Hi all, I have 4 audio tags (songs) in mine html code, everyone with an anchor element for javascript function to start audio. Well, when i click another song before stop the current song, they overlap, because the first song didn't stop... How can do this? Stop the first audio when i choose other? Please Help xD!
3 Answers
![Colin Bell](https://uploads.teamtreehouse.com/production/profile-photos/1100802/micro_10391040_10203865630019070_8593751824903140461_n.jpg)
Colin Bell
29,679 PointsIf you post your code or a codepen of your code, it would be easier to help out.
But a quick general suggestion would be be something like this:
$('.play-button').on('click', function() {
//stop all from playing
//play $(this) one
})
![Michele Smiraglia](https://uploads.teamtreehouse.com/production/profile-photos/3081962/micro_11924237_474460926065917_1443848090266930120_n.jpg)
Michele Smiraglia
6,509 Pointsvar tracks = [document.getElementById('theChill'),
document.getElementById('coolDown'),
document.getElementById('gameDrop'),
document.getElementById('upStorms')];
function ply(tracks) {
tracks.play();
}
function stp(tracks) {
tracks.pause();
tracks.currentTime = 0;
}
![Michele Smiraglia](https://uploads.teamtreehouse.com/production/profile-photos/3081962/micro_11924237_474460926065917_1443848090266930120_n.jpg)
Michele Smiraglia
6,509 PointsColin Bell this is the function to play the tracks and stop it. This is the site: (http://fieldofbeats.com)
![Michele Smiraglia](https://uploads.teamtreehouse.com/production/profile-photos/3081962/micro_11924237_474460926065917_1443848090266930120_n.jpg)
Michele Smiraglia
6,509 PointsPlease someone can help me?