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
jQuery move multi select values from one to another multi select list
JavaScript simple alert on Click
How to set checkbox and radio option checked on load with jQuery?
How to build simple tabs with jQuery?
JavaScript HTML5 Validation for name and email field
JavaScript convert string variable in boolean using Regex
Generate random password for form field on click using JavaScript
How to change the height of Textarea on click?
jQuery Show or Hide text on button click
How to scroll page to 1000px from top on page load using jQuery?