So I'm trying to make an audio element hide after you press "play" but sadly it will not work
Here's the code
var audio = document.querySelector('audio');
audio.addEventListener('play', function() {
audio.style.display = 'none';
audio.removeAttribute('controls');
});
and here's the HTML code
<audio controls autoplay loop>
<source src="Music551.mp3" type="audio/mp3" />
</audio>
also I added some CSS but it's just for it to be at the bottom right
audio {
position: absolute;
bottom: 0;
right: 0;
}
But it's still not working I've tried everything. Also the file is in .php but all the HTML and JavaScript and CSS still works fine so I don't know.
Also the audio element works fine but when I click play, the element is not hiding for some reason.
I was expecting the audio to hide after clicking play.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/dfeCkZ9
Comments
Post a Comment