<button id="red"> Red</button>
<p id="sentence">
My Color Changes to Red Once you click the Button
</p>
.red{
color:red;
}
var colorRed = document.getElementById('red');
var sentence = document.getElementById('sentence');
colorRed.onclick = sentence.className = 'red';
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.