-
-
Save junkafarian/f17eaf1c9c45aac4e517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JavaScript Test | |
--------------- | |
A small script to open a popup when clicking a link. | |
Once you click on the button, clinking on it again will close the popup. | |
*/ | |
/* Task One - Improve this code | |
var close = 'Close List'; | |
var open = 'Open List'; | |
var isOpen = false; | |
var FirstButton = document.getElementById('#1st-button"); | |
var HTMLElement = document.getElementById('#Pop-Up'); | |
var load = fucntion() { | |
FirstButton.innerText = open; | |
FirstButton.addEventListener('onClick', function(Event) { | |
isOpen = isOpen ? false : true; | |
open(HTMLElement, isOpen); | |
if(isOpen) | |
FirstButton.css('background-color', rgba(234,54,43); | |
else | |
FirstButton.innerText = isOpen ? open : close; | |
return isOpen = true; | |
} | |
} | |
var open = function(element, close) { | |
element.css('display', close : 'none' ? 'block'); | |
} | |
window.addEventListener(onLoad, function onLoad() {load()}); | |
open(FirstButton, isOpen); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment