I was able to set the starting color and make the button but when I tried to make it where clicking on the button changed the color, it didnt work
By the way I am using the app QuickEdit for this
let button = document.getElementByld("btn");
let text = document.getElementByld("text");
button.addEventListener('click', function() {
text.style.color = 'green';
})
#text {
color: red;
}
<p id="text">This is a sample text</p>
<button id='btn'>Change text color</button>
New contributor
Jan Kvapil Jr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.