Puoi fare cosi.

Codice PHP:
<!DOCTYPE html>
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Exercise 1</title>

<
script type ="text/javascript">
var 
coloreOriginale null;
function 
changeColor() {
  if (
coloreOriginale == null) {
    
coloreOriginale document.getElementById('box').style.backgroundColor;
  }
  if (
document.getElementById('box').style.backgroundColor == coloreOriginale) {
    
document.getElementById('box').style.backgroundColor "#299930";
  } else {
    
document.getElementById('box').style.backgroundColor coloreOriginale;
  }
// function changeColor()
</script>
<style>
#box {width: 100px;height: 100px;border: 2px solid red;}
</style>
</head>
<body>
<div id ="box" onclick ="changeColor();">Clicca qua</div>
</body>
</html>