Skip to content

Instantly share code, notes, and snippets.

@blabos-zz
Created November 12, 2013 20:20
Show Gist options
  • Save blabos-zz/7437960 to your computer and use it in GitHub Desktop.
Save blabos-zz/7437960 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<script>
document.addEventListener("DOMContentLoaded", function() {
var button;
button = document.getElementById("blue");
button.onclick = function() {
change_color('blue');
};
button = document.getElementById("red");
button.onclick = function() {
change_color('red');
};
function change_color(color) {
var elem = document.getElementById("paragraph");
elem.style.color = color;
}
});
</script>
</head>
<body>
<p id="paragraph">Hello World</p>
<button id="blue">blue</button>
<button id="red">red</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment