Skip to content

Instantly share code, notes, and snippets.

@blacksun1
Created March 26, 2020 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacksun1/f931dbcd05dc247a0d24a7919e02eff1 to your computer and use it in GitHub Desktop.
Save blacksun1/f931dbcd05dc247a0d24a7919e02eff1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xorojum
<!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>
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;
}
(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