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
How to check a variable is undefined in JavaScript?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
How to declare multiple variables in one statement in Javascript?
jQuery simple form with name and email validations
How to current URL, HOST and URL attributes using JavaScript or jQuery?
How to scroll page to 1000px from top on page load using jQuery?