Change element color using button

 

You need to create a on click trigger (Event listener)

Find the element that you want to change colors for by using document. getElementById("someId") and set on click event lister in to variable 

 

document.getElementById('someId').onclick = colorAction;   

function colorAction() {
	document.getElementById('someId').style.color = "purple";
	return true;
}   

Tags:

Share:

Related posts