javascript - How can I use 'ended' event in .on() in jQuery? -


im trying use ended video tag in dynamically generated content on isn't working , idk why, code.

$(document).ready(function() {  $('.container').on('click','.videobox',function(){     var $this = $(this);     var video = $this.next('video')[0];     if (video.paused) {         $this.css({             opacity: 0         });         video.play();     } else {         video.pause();         $this.css({             opacity: 0.5         });     }  }).on("ended",".test",function () { alert('asd');     $(this).prev('.videobox').css({         opacity: 0.5     }); }); }); 

this html

<div class="videobox" style="position: absolute; z-index: 500; background-color: #000; opacity: 0.5; width: 473px; height: 474px;"><img src="/image/camera.png" style="position: relative; top: 45%; margin-left: 160px;"></div> <video class="test" width="473" height="474">   <source src="stuff.mp4" type="video/mp4">   <source src="movie.ogg" type="video/ogg">   browser not support video tag. </video> 


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -