I want to bind a listener to all audio tags (including dynamically added ones) currently on the page that triggers when the user clicks the play button. I was trying it like:
$(document).on("play", "audio", function () {
alert("here");
});
But it doesn't work. I know I can do it the pure JS way. I could probably do something like:
var audioElements = $('audio')
for(i=0;i<audioElements.length;++i) {
audioElements[i].addEventListener('play', function(){
alert("here");
}
}
But a nice JQuery solution would be preferable. Can't find anything online regarding this.