jedihamster jedihamster - 1 year ago 95
Javascript Question

Updated: Javascript Video Fade in Chrome

Update: This works perfectly in Safari but does the action detailed in the original post below in Chrome - any suggestions.

I am using the following video which should fade up on mouse click, the control visibility fades up without issue but the video is on or off (opacity 0 or 1 - all or nothing). Any help appreciated in connecting the video content to the fade, not just the controls - (for the sake of consistency in pure Javascript if possible).

function assets() {
"use strict";
var elem = document.getElementsByTagName("video")[0]; = "opacity 8s linear 0s"; = 1.0;;

video {
opacity: 0;

<a href="#" onClick="assets()">video</a>

<video width="200px" height="200px" controls>

Answer Source

You have to toggle the opacity, try something along the lines of: = Math.abs( - 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download