I am trying to get the hex code to show up in the background color changer I made. Can I use document.getElementById
? Here is my code. I want the Hex code to display when I press the Change Color button? Would I use an array to do this or what would be the best option to use? I trying, to just get better at JS I am really struggling with this so any help would be helpful.
function bcc() {
const color = document.getElementById('changeColor');
color.style.color = newColor;
}
body {
margin: 0;
padding: 0;
background-color: rgb(219, 219, 161);
}
h1,
h2 {
text-align: center;
}
#button {
text-align: center;
margin: 0 0 0 45em;
}
<h1>Background Color Changer</h1>
<h2>RGB Color: </h2>
<br>
<p id="changeColor">
<button onclick="bcc()">Click to change color</button>
</p>