Reputation: 1175
hello I'm trying to let this audio stop, but I can't find any way to do so:
$('<audio id="elevator" autoplay loop preload="auto" autobuffer><source src="elevator.mp3" /><source src="elevator.ogg" /></audio>').appendTo('body');
$('#elevator').pause();
Upvotes: 1
Views: 4813
Reputation: 144659
pause()
is not a jQuery method, you should first convert the jQuery object to a raw DOM element and then call the pause()
method, try this:
$('#elevator')[0].pause();
or:
document.getElementById('elevator').pause()
or:
document.getElementsByTagName('audio')[0].pause()
Upvotes: 7