Skip to content

Instantly share code, notes, and snippets.

@ehzawad
Created February 9, 2019 23:15
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 ehzawad/7feec7cdc41b81a4b336515ac17e4b04 to your computer and use it in GitHub Desktop.
Save ehzawad/7feec7cdc41b81a4b336515ac17e4b04 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Change font color to red
document.querySelector('#red').onclick = function() {
document.querySelector('#hello').style.color = 'red'
}
// Change font color to blue
document.querySelector('#blue').onclick = function() {
document.querySelector('#hello').style.color = 'blue'
}
// Change font color to green
document.querySelector('#green').onclick = function() {
document.querySelector('#hello').style.color = 'green'
}
})
</script>
<title>Efat</title>
</head>
<body>
<h1 id="hello">Hello!!</h1>
<button id="red">Red</button>
<button id="blue">blue</button>
<button id="green">green</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment