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
Edit the text of label on click using jQuery
How to the length of the longest word in the provided sentence?
How to change text after click event using JavaScript?
How to show hide option list items using jQuery?
How to declare and print value of variable in JavaScript?
Write a function that splits an array into groups the length of size and returns them as a two-dimensional array