Skip to content

Instantly share code, notes, and snippets.

@Bijesse
Created May 2, 2021 14:30
Show Gist options
  • Save Bijesse/702abe71de47b8604b8e81423d99ebf0 to your computer and use it in GitHub Desktop.
Save Bijesse/702abe71de47b8604b8e81423d99ebf0 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=702abe71de47b8604b8e81423d99ebf0
<!DOCTYPE html>
<html>
<head>
<title>Click Handler Background Color</title>
</head>
<body>
<input id="age">
<button id="user-age">Your age</button>
</body>
</html>
{"hiddenUIComponents":["console"]}
document.getElementById("user-age").addEventListener("click", changeButtonColor);
function changeButtonColor(){
var color = document.getElementById("age").value;
document.getElementById("user-age").style.background = color;
}
#user-age {
background: yellow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment