Created
March 26, 2020 00:35
-
-
Save blacksun1/f931dbcd05dc247a0d24a7919e02eff1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xorojum
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
background-color: teal; | |
} | |
#toilet { | |
display:block; | |
height: 100px; | |
width: 100px; | |
background-color: AliceBlue; | |
text-align: center; | |
border: solid 5px GhostWhite; | |
border-radius: 50% | |
} | |
#toilet.poo { | |
background: brown; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="toilet"> | |
<button id="flush" type="button">Flush!</button><br /> | |
<button id="poo" type="button">Poo</button> | |
</div> | |
<script id="jsbin-javascript"> | |
(function() { | |
const toilet = document.getElementById("toilet"); | |
function handleToiletActions(event) { | |
switch(event.target.id) { | |
case 'flush': | |
event.preventDefault(); | |
flush(); | |
break; | |
case 'poo': | |
event.preventDefault(); | |
poo(); | |
break; | |
} | |
} | |
function flush(event, a, b) { | |
toilet.classList.remove("poo"); | |
} | |
function poo() { | |
toilet.classList.add("poo"); | |
} | |
toilet.addEventListener("click", handleToiletActions); | |
}()); | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
background-color: teal; | |
} | |
#toilet { | |
display:block; | |
height: 100px; | |
width: 100px; | |
background-color: AliceBlue; | |
text-align: center; | |
border: solid 5px GhostWhite; | |
border-radius: 50% | |
} | |
#toilet.poo { | |
background: brown; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">(function() { | |
const toilet = document.getElementById("toilet"); | |
function handleToiletActions(event) { | |
switch(event.target.id) { | |
case 'flush': | |
event.preventDefault(); | |
flush(); | |
break; | |
case 'poo': | |
event.preventDefault(); | |
poo(); | |
break; | |
} | |
} | |
function flush(event, a, b) { | |
toilet.classList.remove("poo"); | |
} | |
function poo() { | |
toilet.classList.add("poo"); | |
} | |
toilet.addEventListener("click", handleToiletActions); | |
}()); | |
</script></body> | |
</html> |
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
body { | |
background-color: teal; | |
} | |
#toilet { | |
display:block; | |
height: 100px; | |
width: 100px; | |
background-color: AliceBlue; | |
text-align: center; | |
border: solid 5px GhostWhite; | |
border-radius: 50% | |
} | |
#toilet.poo { | |
background: brown; | |
} |
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
(function() { | |
const toilet = document.getElementById("toilet"); | |
function handleToiletActions(event) { | |
switch(event.target.id) { | |
case 'flush': | |
event.preventDefault(); | |
flush(); | |
break; | |
case 'poo': | |
event.preventDefault(); | |
poo(); | |
break; | |
} | |
} | |
function flush(event, a, b) { | |
toilet.classList.remove("poo"); | |
} | |
function poo() { | |
toilet.classList.add("poo"); | |
} | |
toilet.addEventListener("click", handleToiletActions); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment