I want to change the color of a button when it is clicked and have added this getElementById line in the function called by onclick but when I add the line the function won't run. Any ideas what might be wrong with it? The function also contains AJAX to change the button content but everything else is working fine as long as I don't add this line.


Code:
<input type = "button" id = "alternative1" value="$alt1" onClick="changeQuestion('alternative1')">

function changeQuestion(answer)
	{
document.getElementById(answer).style.backgroundColor = "#A9A9A9";
	}
Many thanks