Created
June 28, 2014 07:22
-
-
Save oddurs/9e9c5f65f7962e40ac24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#box { | |
width: 50px; | |
height: 50px; | |
background: blue; | |
top: 150px; | |
left: 10px; | |
} | |
.normal { | |
background-color: white; | |
color: black; | |
} | |
.changed { | |
background-color: black; | |
color: white; | |
} |
This file contains hidden or 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 name="description" content="Event handlers lesson" /> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body class="normal"> | |
<h1>Hello, events</h1> | |
<p>la di da</p> | |
<button>Normal</button><button>Changed</button> | |
</body> | |
</html> |
This file contains hidden or 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() { | |
var button = document.getElementsByTagName("button"); | |
for (var i = 0, len = button.length; i < len; i++) { | |
button[i].onclick = function() { | |
var className = this.innerHTML.toLowerCase(); | |
document.body.className = className; | |
}; | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment