Example
Learn the test-driven development approach when building apps
<!DOCTYPE html>
<html>
<head>
<title>Change Color</title>
</head>
<body>
<button id="changeGreen">Change Font Color Green</button>
<button id="changeRed">Change Font Color Red</button>
<p>
<span id="output">Learn the test-driven development approach when building apps</span>
</p>
<script>
document.getElementById("changeGreen").onclick = function(){
document.getElementById("output").style.color = 'green';
}
document.getElementById("changeRed").onclick = function(){
document.getElementById("output").style.color = 'red';
}
</script>
</body>
</html>
Most Helpful This Week
JavaScript sort multi dimensional array on specific columns
What's the difference between let and var?
Using jQuery delete table row on click
How to change text after click event using JavaScript?
jQuery move multi select values from one to another multi select list
jQuery get the coordinates of div clicked