Chnage Color on Vanila JS
by syjsdev
HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="red" style="color: blue"> Paragrafo 01</p>
<input type="button" value="cor" onclick="mudarred();" />
<script>
function mudarred() {
if (document.getElementById('red').style.color == "red")
document.getElementById('red').style.color = "blue";
else
document.getElementById('red').style.color = "red";
}
</script>
</body>
</html>