Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery remove() html 5 audio mediaelementjs

Hi I have a simple problem and I hope there is a simple solution.

I have an HTML audio element on my page

<audio id='foo' control="control">
    <source id='mp3' src='somefile.mp3' type='audio/mp3'>
</audio>

In jQuery I have $('audio').remove(); but the audio player stays on the page. I have also tried $('#foo').remove();.

I'm using the mediaelementjs player, I don't know if that is what is causing the problem.

Anyone know how I can remove audio elements?

Thanks

like image 374
David Healey Avatar asked Mar 18 '26 04:03

David Healey


1 Answers

You could wrap it in a placeholder div and then do $("#wrapper").html("");

like image 69
corymathews Avatar answered Mar 19 '26 21:03

corymathews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!