using javascript/jquery, why is this working:
var vid = document.getElementById("bgvid");
function stopVideo() {
vid.pause();
}
setTimeout(stopVideo, 2000);
But not this:
var vid = $('#bgvid');
function stopVideo() {
vid.pause();
}
setTimeout(stopVideo, 2000);
conversely, when I try to fade the same video later on, this works:
$('#bgvid').parent().delay(13000).fadeOut(2000);
but this doesn't:
vid.parent().delay(13000).fadeOut(2000);
I thought the var "vid" which is getting the video element by its id would be equivalent to $('#bgvid')...
And also and more importantly, I have an element that appears and fades out after a set time:
var element = $( '#element' );
element.hide().delay(6000).fadeIn(500).delay(6000).fadeOut(500);
and I also would like to make it fade if the user clicks so I have tried this:
$( document ).on('click', function(){
element.fadeOut(500);
});
but when I click nothing happens and the element does not fade out. No errors on the console. Thank you for your time.