Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2011, 05:42
otherhet
 
Fecha de Ingreso: junio-2011
Mensajes: 2
Antigüedad: 12 años, 11 meses
Puntos: 0
Cambiar style con javascript

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> 
Me gustaría que al hacer clic en el enlace cambiasen los colores de la letra y del fondo del div divito pero no me funciona ¿Qué he hecho mal?