Jump to content

Turn video controls on/off


Recommended Posts

UPDATE:  Oh, gee!  Never mind.  I'm just blind.  I needed doh == true, not doh=true.

My page loads a video file.  I desire a button that turns the video controls on and off.  For the life of me, I can't figure out what I'm doing wrong in the code below.  The var "doh" correctly identifies whether the video controls are on (true) or off (false).  However, the IF statement always evaluates as if "doh" is TRUE.  What in the heck is wrong with my IF statement?


        document.getElementById("showControls").addEventListener("click", function (evt) {
            var doh = video.controls;
            if (doh = true) {
                alert("in if doh=true clause");
                video.controls = false;
                evt.target.innerHTML = "<img alt='Show' />"
            } else {
                alert("in if doh=false clause");
                video.controls = true;
                evt.target.innerHTML = "<img alt='Hide' />"
        }, false);


Edited by SerenityNetworks
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...