add ann identifier to video control
function addvideo() { var addvideo = $('<video controls="controls" width="480" height="208" id="videoo"><source src="http://devfiles.myopera.com/articles/2642/sintel-trailer.ogv" type="video/ogg; codecs="theora, vorbis""><source src="http://devfiles.myopera.com/articles/2642/sintel-trailer.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2""></video>'); $(addvideo).appendTo('body'); }
use delegate as the button you add is dynamic
$(document).delegate('.playbtn',"click",function () { $('#videoo')[0].play(); });
$("#videoo")[0]
will return you a DOM element, not a jQuery object, since the play
method is not a jquery method, its a DOM method
Demo
Rafay source share