Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function toggle(customID) { // Function set on button, 'customID' is the ID
- // of element to toggle with button. Ex:
- // <button onclick="(toggle('menu')">Button</button>
- var theToggledElement = document.getElementById(customID);
- var currentState = false; // false = hidden. true = visible.
- if (currentState === false) {
- currentState = true;
- theToggledElement.style.left = '0px';
- console.log('State set to "visible" and left to "0px"');
- }
- else if (currentState === true) {
- currentState = false;
- theToggledElement.style.left = 'calc(-100% + (0.5cm + 1.461544602cm + .5cm))';
- console.log('State set to "hidden" and left to "calc(-100% + (0.5cm + 1.461544602cm + .5cm))"')
- }
- }
Add Comment
Please, Sign In to add comment