How to pause the audio with javascript?

Hello i’ve a code to play audio with an audioplayer, but if the user goes to another screen with the (Back arrow <) the audio still continues. How do i pause this audio with a onclick event? Does anyone know?

javascript:void( $(‘[data-label=“audioPlayer”]’).append(“<audio controls id=‘player’><source src=‘https://docs.google.com/uc?export=open&amp;id=11NdWruFqIrM8xNdh2lVNN-LAlT7Rfhpz’ type=‘audio/mp3’>Your browser does not support the audio element.</audio>”) );

1 Like

Solved javascript:void( $("#player")[0].pause() );

Minor point, but you don’t need the void(&()) unless you are directly changing a page element.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.