I try to execute a function on an audio play
event :
jQuery('audio').on('play', function () { /* ... */ });
But my element is not present at the time this function is executed, so it's not selected. Instead I have the habit to use a different syntax when I need to trigger event for dynamic added content :
jQuery('.constant-container').on('play', 'audio', function () {
/* ... */
});
Where the .constant-container
does not change.
But this solution does not seems to work, the audio element does not get any click
event either.
Here is a link to the bin.
The first 4 audio handle correctly the event, but not the 4 last.