Last active
July 12, 2016 16:12
-
-
Save victoriachuang/8ab18121ce03d6b3015ac05ff58a4dd3 to your computer and use it in GitHub Desktop.
Change font size of an HTML document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = document.getElementById('text'); | |
var small = document.getElementById('small'); | |
var large = document.getElementById('large'); | |
small.onclick = function() { | |
text.style.fontSize = '12px'; | |
} | |
large.onclick = function() { | |
text.style.fontSize = '20px'; | |
} | |
// | |
// refactored to reduce copy-and-paste | |
// | |
// function changeFont(size) { | |
// text.style.fontSize = size + 'px'; | |
// } | |
// | |
// small.onclick = function() { | |
// changeFont(12); | |
// } | |
// | |
// large.onclick = function() { | |
// changeFont(20); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment