function changeSize( fontsize ) {
var body = document.getElementById("body");
var font = fontsize + "-font";
body.className = font;
}
<input type="button" onclick="changeSize(small)" value="Small" />
Firefox console keeps saying that small is undefined. What am I doing wrong?
You’re passing in
smallas a variable, not a string to put into the DOM. Javascript is looking for thevar smallto be defined somewhere, and it’s not. You need to pass in a string as an argument.Try
onclick="changeSize('small')"