Skip to content

Instantly share code, notes, and snippets.

@rodvan
Created January 30, 2015 08:02
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 rodvan/25b10122747298866d58 to your computer and use it in GitHub Desktop.
Save rodvan/25b10122747298866d58 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#box {
background-color: Blue;
height: 100px;
left: 50px;
position: absolute;
top: 50px;
width: 100px;
}
</style>
</head>
<body>
<div id="box"></div>
<script id="jsbin-javascript">
var el = document.getElementById("box");
el.onclick = function() {
var checkColor = this.style.backgroundColor;
if (checkColor === "red") {
this.style.backgroundColor = "blue";
} else {
this.style.backgroundColor = "red";
}
};
</script>
<script id="jsbin-source-css" type="text/css">#box {
background-color: Blue;
height: 100px;
left: 50px;
position: absolute;
top: 50px;
width: 100px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var el = document.getElementById("box");
el.onclick = function() {
var checkColor = this.style.backgroundColor;
if (checkColor === "red") {
this.style.backgroundColor = "blue";
} else {
this.style.backgroundColor = "red";
}
};</script></body>
</html>
#box {
background-color: Blue;
height: 100px;
left: 50px;
position: absolute;
top: 50px;
width: 100px;
}
var el = document.getElementById("box");
el.onclick = function() {
var checkColor = this.style.backgroundColor;
if (checkColor === "red") {
this.style.backgroundColor = "blue";
} else {
this.style.backgroundColor = "red";
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment