Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/03/2012, 11:59
Avatar de Ex_shadow
Ex_shadow
 
Fecha de Ingreso: febrero-2012
Ubicación: Calera Avellaneda, Buenos Aires, Argentina, Argentina
Mensajes: 95
Antigüedad: 13 años
Puntos: 4
Pregunta Javascript funcion $()

Hola les paso a mostrar mi script.

El único problema que tengo es el de no saber por que no funciona.

La cosa seria que al definir $( (#- id) (. - Clase) (@ - Nombre) div ) tendria que cambiarse el fondo va, el script habla mejor que yo xD

Código Javascript:
Ver original
  1. function $(id){
  2.    
  3.     /* --- Toma el valor 0 de id --- */
  4.     var Identificador = id.charAt(0);
  5.  
  6.     /* --- Selecciona id,clase,nombre--- */
  7.     switch(Identificador){
  8.         case '#': document.getElementById(id).style.background='#000';   break;
  9.         case '.': document.getElementsByClassName(id).style.background='#000';   break;
  10.         case '@': document.getElementsByName(id).style.background='#000';   break;
  11.         default : document.getElementsByTagName(id).style.background='#000';
  12.     }
  13. }

Código HTML:
Ver original
  1. <script type="application/javascript">
  2.     $('#div')
  3.  
  4. <div id="div">Soy un comentario.</div>