How can I toggle a class in CSS using JavaScript?

Script It is changing slash eye to eye but not vice versa. How can I achieve that? Answer You are just removing the class with remove method. Your question almost answered itself, as the solution to it is the toggle method. With this simple change, your code should behave as you expect now.

Toggle visibility property of div

I have an HTML 5 video in a div. I then have a custom play button – that works fine. And I have the video’s visibility set to hidden on load and visible when the play button is clicked, how do I …

How to toggle a boolean?

Is there a really easy way to toggle a boolean value in javascript? So far, the best I’ve got outside of writing a custom function is the ternary: bool = bool ? false : true;