var $video = $(''); $video.insertAfter(banner); $video.on('ended', function(){ //do something when video ends });