Created
November 12, 2013 20:20
-
-
Save blabos-zz/7437960 to your computer and use it in GitHub Desktop.
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> | |
<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