Código HTML:
<style> #divito{ color: #000; background: #fff; } </style> <script> var divitostat = 1; function depende(){ if (divitostat == 1){ invertido(); divitostat = 2; } if (divitostat == 2){ normal(); divitostat = 1; } } function invertido(){ document.getElementbyId("divito").style.color = "#fff"; document.getElementbyId("divito").style.background = "#000"; } function normal(){ document.getElementbyId("divito").style.color = "#000"; document.getElementbyId("divito").style.background = "#fff"; } </script> <div id="divito">Este es divito</div> <a href="javascript:depende();">Invertir colores</a>