Guest User

Untitled

a guest
Jun 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. function toggle(customID) { // Function set on button, 'customID' is the ID
  2. // of element to toggle with button. Ex:
  3. // <button onclick="(toggle('menu')">Button</button>
  4. var theToggledElement = document.getElementById(customID);
  5. var currentState = false; // false = hidden. true = visible.
  6.  
  7. if (currentState === false) {
  8. currentState = true;
  9. theToggledElement.style.left = '0px';
  10. console.log('State set to "visible" and left to "0px"');
  11. }
  12. else if (currentState === true) {
  13. currentState = false;
  14. theToggledElement.style.left = 'calc(-100% + (0.5cm + 1.461544602cm + .5cm))';
  15. console.log('State set to "hidden" and left to "calc(-100% + (0.5cm + 1.461544602cm + .5cm))"')
  16. }
  17. }
Add Comment
Please, Sign In to add comment